From: abd Date: Mon, 28 Apr 2008 06:18:30 +0000 (+0000) Subject: Correct compilation on Linux X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d33562205899fdf5fadf65245d858c24cfd0179f;p=modules%2Fkernel.git Correct compilation on Linux --- diff --git a/bin/Makefile.am b/bin/Makefile.am index 2cf221ead..b8086e529 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -72,20 +72,23 @@ EXTRA_DIST = appliskel dist-hook: rm -rf `find $(distdir)/appliskel -name CVS` -DISTCLEANFILES = $(top_builddir)/bin/@PACKAGE@/Makefile.am +DISTCLEANFILES = $(top_builddir)/bin/salome/Makefile.am clean-local: - rm -rf $(top_builddir)/bin/@PACKAGE@/appliskel - cd $(top_builddir)/bin/@PACKAGE@; \ + rm -rf $(top_builddir)/bin/salome/appliskel + cd $(top_builddir)/bin/salome; \ rm -f $(dist_salomescript_DATA) $(dist_salomescript_SCRIPTS) # This is an ugly target to avoid exploring the appliskel subdirectory. install-exec-local: - $(INSTALL) -d $(salomescriptdir) - $(RM) -rf $(salomescriptdir)/appliskel 1> /dev/null 2>&1 - cp -r $(srcdir)/appliskel $(salomescriptdir) - find $(salomescriptdir) -name CVS -prune -exec rm -rf {} \; + $(INSTALL) -d $(DESTDIR)$(salomescriptdir) + $(RM) -rf $(DESTDIR)$(salomescriptdir)/appliskel 1> /dev/null 2>&1 + cp -r $(srcdir)/appliskel $(DESTDIR)$(salomescriptdir) + find $(DESTDIR)$(salomescriptdir) -name CVS -prune -exec rm -rf {} \; uninstall-local: - find $(salomescriptdir)/appliskel -exec chmod +w {} \; - rm -rf $(salomescriptdir)/appliskel + if test -d $(DESTDIR)$(salomescriptdir)/appliskel; then \ + find $(DESTDIR)$(salomescriptdir)/appliskel -exec chmod +w {} ';' ; \ + rm -rf $(DESTDIR)$(salomescriptdir)/appliskel; \ + fi; + diff --git a/bin/appli_clean.sh b/bin/appli_clean.sh index 0046e946c..169a56622 100644 --- a/bin/appli_clean.sh +++ b/bin/appli_clean.sh @@ -20,4 +20,4 @@ # #clean appli -rm -rf bin lib share doc env.d envd setAppliPath.sh searchFreePort.sh runAppli runConsole runSession runRemote.sh runTests SalomeApp.xml *.pyc *~ .bashrc +rm -rf bin lib share doc env.d envd getAppliPath.py searchFreePort.sh runAppli runConsole runSession runRemote.sh runTests SalomeApp.xml *.pyc *~ .bashrc diff --git a/bin/appli_gen.py b/bin/appli_gen.py index c24614cc1..1ce244aca 100644 --- a/bin/appli_gen.py +++ b/bin/appli_gen.py @@ -145,7 +145,7 @@ def install(prefix,config_file): appliskel_dir=os.path.join(home_dir,'bin','salome','appliskel') for fn in ('envd', - 'setAppliPath.sh', + 'getAppliPath.py', 'searchFreePort.sh', 'runRemote.sh', 'runAppli', @@ -154,7 +154,7 @@ def install(prefix,config_file): 'runTests', '.bashrc', ): - virtual_salome.symlink(os.path.join(appliskel_dir, fn),os.path.join(home_dir, fn)) + virtual_salome.symlink("./bin/salome/appliskel/"+fn,os.path.join(home_dir, fn)) pass if filename != os.path.join(home_dir,"config_appli.xml"): @@ -174,7 +174,7 @@ def install(prefix,config_file): f =open(os.path.join(home_dir,'env.d','configSalome.sh'),'w') for module in _config["modules"]: - command='export '+ module + '_ROOT_DIR=' + home_dir +'\n' + command='export '+ module + '_ROOT_DIR=${HOME}/${APPLI}\n' f.write(command) pass if _config.has_key("samples_path"): @@ -185,9 +185,9 @@ def install(prefix,config_file): f =open(os.path.join(home_dir,'env.d','configGUI.sh'),'w') - command = 'export SalomeAppConfig=' + home_dir +'\n' + command = 'export SalomeAppConfig=${HOME}/${APPLI}\n' f.write(command) - command = 'export SUITRoot=' + os.path.join(home_dir,'share','salome') +'\n' + command = 'export SUITRoot=${HOME}/${APPLI}/share/salome\n' f.write(command) f.write('export DISABLE_FPE=1\n') f.write('export MMGT_REENTRANT=1\n') diff --git a/bin/appli_install.sh b/bin/appli_install.sh index 37da0092e..5e0dc418a 100644 --- a/bin/appli_install.sh +++ b/bin/appli_install.sh @@ -25,13 +25,13 @@ INSTALL_ROOT=${SALOME_ROOT}/Install APPLI_ROOT=`pwd` # --- clean appli -rm -rf bin lib share doc envd setAppliPath.sh searchFreePort.sh runAppli runConsole runSession env.d +rm -rf bin lib share doc envd getAppliPath.py searchFreePort.sh runAppli runConsole runSession env.d # --- install appli mkdir -p env.d ln -fs bin/salome/appliskel/envd . -ln -fs bin/salome/appliskel/setAppliPath.sh . +ln -fs bin/salome/appliskel/getAppliPath.py . ln -fs bin/salome/appliskel/searchFreePort.sh . ln -fs bin/salome/appliskel/runRemote.sh . ln -fs bin/salome/appliskel/runAppli . diff --git a/bin/appliskel/CatalogResources.xml b/bin/appliskel/CatalogResources.xml index 8caed2bfb..9e09ed5fc 100644 --- a/bin/appliskel/CatalogResources.xml +++ b/bin/appliskel/CatalogResources.xml @@ -1,28 +1,4 @@ - - - - - + diff --git a/bin/appliskel/README b/bin/appliskel/README index 644da2122..21ee467ac 100644 --- a/bin/appliskel/README +++ b/bin/appliskel/README @@ -57,7 +57,7 @@ SALOME internal run scripts envd Sets SALOME application environment, envd is sourced by other scripts. -setAppliPath.sh +getAppliPath.py Used by other scripts to define the Application Path. searchFreePort.sh diff --git a/bin/appliskel/killCurrentPort b/bin/appliskel/killCurrentPort index 41b14866a..c9f1e6c9d 100755 --- a/bin/appliskel/killCurrentPort +++ b/bin/appliskel/killCurrentPort @@ -2,7 +2,8 @@ # --- retrieve APPLI path, relative to $HOME, set ${APPLI} -. `dirname $0`/setAppliPath.sh +APPLI_HOME=`dirname $0` +export APPLI=`${APPLI_HOME}/getAppliPath.py` # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) diff --git a/bin/appliskel/runAppli b/bin/appliskel/runAppli index 2bd9f1dae..a18114dd6 100755 --- a/bin/appliskel/runAppli +++ b/bin/appliskel/runAppli @@ -4,7 +4,7 @@ APPLI_HOME=`dirname $0` # --- retrieve APPLI path, relative to $HOME, set ${APPLI} -. ${APPLI_HOME}/setAppliPath.sh +export APPLI=`${APPLI_HOME}/getAppliPath.py` # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) diff --git a/bin/appliskel/runConsole b/bin/appliskel/runConsole index c94a02fcf..73f5f5f88 100755 --- a/bin/appliskel/runConsole +++ b/bin/appliskel/runConsole @@ -4,7 +4,7 @@ APPLI_HOME=`dirname $0` # --- retrieve APPLI path, relative to $HOME, set ${APPLI} -. ${APPLI_HOME}/setAppliPath.sh +export APPLI=`${APPLI_HOME}/getAppliPath.py` # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) diff --git a/bin/appliskel/runRemote.sh b/bin/appliskel/runRemote.sh index 21bc0b0c1..522b6ddd7 100755 --- a/bin/appliskel/runRemote.sh +++ b/bin/appliskel/runRemote.sh @@ -37,12 +37,14 @@ # $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 +# $3 : working directory +# $4 and following : local command to execute, with args # # --- retrieve APPLI path, relative to $HOME, set ${APPLI} -. `dirname $0`/setAppliPath.sh +APPLI_HOME=`dirname $0` +export APPLI=`${APPLI_HOME}/getAppliPath.py` # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) @@ -59,9 +61,34 @@ export NSPORT initref="NameService=corbaname::"$1":$2" echo "ORBInitRef $initref" > $OMNIORB_CONFIG +#go to the requested working directory if any +if test "x$3" != x; then + if test "x$3" = "x\$TEMPDIR"; then + #create a temp working dir and change to it + WDIR=`mktemp -d` && { + cd $WDIR + } + else + if test -d $3; then + #the dir exists, go to it + cd $3 + else + if test -a $3; then + # It's a file do nothing + echo $3 "is an existing file. Can't use it as a working directory" + else + #It does not exists, create it + mkdir -p $3 && { + cd $3 + } + fi + fi + fi +fi + # --- execute the command in the SALOME environment -shift 2 +shift 3 # suppress --rcfile option because of problem on Mandriva2006 - B Secher mai 2007 #${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/sh --rcfile $HOME/$APPLI/.bashrc -c "$*" diff --git a/bin/appliskel/runSession b/bin/appliskel/runSession index 9f3b0e4f9..446ee605a 100755 --- a/bin/appliskel/runSession +++ b/bin/appliskel/runSession @@ -9,7 +9,7 @@ APPLI_HOME=`dirname $0` # --- retrieve APPLI path, relative to $HOME, set ${APPLI} -. ${APPLI_HOME}/setAppliPath.sh +export APPLI=`${APPLI_HOME}/getAppliPath.py` # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) diff --git a/bin/appliskel/runTests b/bin/appliskel/runTests index e98c1e6aa..4eb9b6dba 100755 --- a/bin/appliskel/runTests +++ b/bin/appliskel/runTests @@ -2,7 +2,8 @@ # --- retrieve APPLI path, relative to $HOME, set ${APPLI} -. `dirname $0`/setAppliPath.sh +APPLI_HOME=`dirname $0` +export APPLI=`${APPLI_HOME}/getAppliPath.py` # --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 150f15598..399c40ef7 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -586,6 +586,15 @@ def CreateOptionParser (theAdditionalOptions=[]): dest="pinter", help=help_str) + # Print Naming service port into a user file. Default: False. + help_str = "Print Naming Service Port into a user file." + o_nspl = optparse.Option("--ns-port-log", + metavar="", + type="string", + action="store", + dest="ns_port_log_file", + help=help_str) + # All options opt_list = [o_t,o_g, # GUI/Terminal o_d,o_o, # Desktop @@ -604,13 +613,14 @@ def CreateOptionParser (theAdditionalOptions=[]): o_c, # Catch exceptions o_a, # Print free port and exit o_n, # --nosave-config - o_pi] # Interactive python console + o_pi, # Interactive python console + o_nspl] #std_options = ["gui", "desktop", "log_file", "py_scripts", "resources", # "xterm", "modules", "embedded", "standalone", # "portkill", "killall", "interp", "splash", - # "catch_exceptions", "print_port", "save_config"] + # "catch_exceptions", "print_port", "save_config", "ns_port_log_file"] opt_list += theAdditionalOptions @@ -811,6 +821,10 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"): else: args[file_nam] = [cmd_opts.log_file] + # Naming Service port log file + if cmd_opts.ns_port_log_file is not None: + args["ns_port_log_file"] = cmd_opts.ns_port_log_file + # Python scripts args[script_nam] = [] if cmd_opts.py_scripts is not None: diff --git a/bin/runSalome.py b/bin/runSalome.py index 6c01d90e4..f20b50794 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -393,6 +393,18 @@ def startSalome(args, modules_list, modules_root_dir): # clt=orbmodule.client(args) + # Save Naming service port name into + # the file args["ns_port_log_file"] + if args.has_key('ns_port_log_file'): + home = os.environ['HOME'] + appli= os.environ.get("APPLI") + if appli is not None: + home='%s/%s'%(home,appli) + pass + file_name= '%s/%s'%(home, args["ns_port_log_file"]) + f = open(file_name, "w") + f.write(os.environ['NSPORT']) + f.close() # (non obligatoire) Lancement Logger Server # et attente de sa disponibilite dans le naming service @@ -784,7 +796,6 @@ def searchFreePort(args, save_config=1): else: system('ln -s -f %s %s/.omniORB_last.cfg'%(os.environ['OMNIORB_CONFIG'], home)) pass - # break print "%s"%(NSPORT), if NSPORT == limit: diff --git a/configure.ac b/configure.ac index 1ef7ba68c..4d28fad9f 100644 --- a/configure.ac +++ b/configure.ac @@ -4,8 +4,7 @@ # ================================================================ # #AC_PREREQ(2.59) -#AC_INIT(src) -AC_INIT([Salome2 Project], [4.1.1], [paul.rascle@edf.fr], [salome]) +AC_INIT([Salome2 Project], [4.1.1], [paul.rascle@edf.fr], [SalomeKer]) # AC_CONFIG_AUX_DIR defines an alternative directory where to find the auxiliary # scripts such as config.guess, install-sh, ... @@ -15,12 +14,7 @@ AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([tar-pax]) #AC_CONFIG_HEADER([config.h]) -PACKAGE=salome -AC_SUBST(PACKAGE) - -VERSION=4.1.1 XVERSION=0x040101 -AC_SUBST(VERSION) AC_SUBST(XVERSION) # set up MODULE_NAME variable for dynamic construction of directories (resources, etc.) @@ -425,7 +419,7 @@ summary $basic_mandatory_products check_fatal_error $basic_mandatory_products echo -corba_mandatory_products="omniORB_ok boost_ok libxml_ok" +corba_mandatory_products="omniORB_ok omniORBpy_ok boost_ok libxml_ok" if test x$corba_gen = xtrue; then echo --- CORBA mandatory products - default configuration: summary $corba_mandatory_products @@ -447,7 +441,7 @@ echo --- Kernel parallel extensions: summary $parallel_products echo -optional_products="cppunit_ok openpbs_ok lsf_ok" +optional_products="cppunit_ok openpbs_ok lsf_ok numpy_ok" echo --- Optional products: echo [" These products are optional because the KERNEL functions"] echo [" using them are built only if the products are detected."] diff --git a/doc/salome/Makefile.am b/doc/salome/Makefile.am index 86089e1b9..9f43889c1 100644 --- a/doc/salome/Makefile.am +++ b/doc/salome/Makefile.am @@ -30,7 +30,7 @@ SUBDIRSGUI= tui SUBDIRSTUI= tui index_html: - $(INSTALL) -d $(docdir); + $(INSTALL) -d $(DESTDIR)$(docdir); usr_docs: index_html list='$(SUBDIRSGUI)'; for subdir in $$list; do \ @@ -48,7 +48,9 @@ dev_docs: index_html info_TEXINFOS = Batch.texi install-data-local: html usr_docs - cp -rp $(top_builddir)/doc/salome/Batch.html $(docdir) + cp -rp $(top_builddir)/doc/salome/Batch.html $(DESTDIR)$(docdir) +uninstall-local: + rm -rf $(DESTDIR)$(docdir)/Batch.html EXTRA_DIST= main.dox install.dox \ kernel_resources.dox kernel_services.dox \ diff --git a/doc/salome/tui/Makefile.am b/doc/salome/tui/Makefile.am index 9088dfa1c..794840fc4 100644 --- a/doc/salome/tui/Makefile.am +++ b/doc/salome/tui/Makefile.am @@ -25,12 +25,16 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am -EXTRA_DIST = KERNEL pythfilter.py +EXTRA_DIST = pythfilter.py dist-hook: + cp -rf $(srcdir)/KERNEL $(distdir) + if test -d "KERNEL"; then \ + find "KERNEL" -name "*.*" -exec cp -rf {} $(distdir)/KERNEL ';' ; \ + fi rm -rf `find $(distdir) -name CVS` -usr_docs: +KERNEL/main.html:../main.dox cp -fr $(srcdir)/KERNEL/* ./INPUT; \ cd ./INPUT; \ pwd; ls;\ @@ -48,21 +52,34 @@ usr_docs: fi; \ $(DOXYGEN) ./doxyuser1; \ cd ..; -# $(INSTALL) -d $(docdir)/tui/KERNEL; - cp -fr $(srcdir)/KERNEL/sources/static/*.* $(docdir); - cp -fr $(srcdir)/KERNEL/sources/ $(docdir); - cp -fr KERNEL/[a-f]*.* $(docdir) - cp -fr KERNEL/[g-l]*.* $(docdir) - cp -fr KERNEL/[m-z]*.* $(docdir) - cp -fr $(srcdir)/KERNEL/HTML/ $(docdir); - cp -f $(srcdir)/pythfilter.py $(docdir); - cp -fr $(srcdir)/KERNEL/exemple/ $(docdir); -# cp -fr $(srcdir)/KERNEL/sources/static/*.* $(docdir)/tui/KERNEL; -# cp -fr $(srcdir)/KERNEL/sources/ $(docdir)/tui/KERNEL; -# cp -fr KERNEL $(docdir)/tui -# cp -fr $(srcdir)/KERNEL/HTML/ $(docdir)/tui/KERNEL; -# cp -f $(srcdir)/pythfilter.py $(docdir)/tui/KERNEL; -# cp -fr $(srcdir)/KERNEL/exemple/ $(docdir)/tui/KERNEL; + +usr_docs:KERNEL/main.html + if test -d "KERNEL"; then b=; else b="$(srcdir)/"; fi; \ + cp -fr $(srcdir)/KERNEL/sources/static/*.* $(DESTDIR)$(docdir); \ + cp -fr $(srcdir)/KERNEL/sources/ $(DESTDIR)$(docdir); \ + find $$b"KERNEL" -name "*.*" -exec cp -rf {} $(DESTDIR)$(docdir) ';' ; \ + cp -fr $(srcdir)/KERNEL/HTML/ $(DESTDIR)$(docdir); \ + cp -f $(srcdir)/pythfilter.py $(DESTDIR)$(docdir); \ + cp -fr $(srcdir)/KERNEL/exemple/ $(DESTDIR)$(docdir); + +uninstall-local: + chmod +w $(DESTDIR)$(docdir)/sources + chmod +w $(DESTDIR)$(docdir)/sources/static + chmod +w $(DESTDIR)$(docdir)/HTML + chmod +w $(DESTDIR)$(docdir)/exemple + rm -rf $(DESTDIR)$(docdir)/pythfilter.py + find $(DESTDIR)$(docdir) -name "*.html" -type f -exec rm -rf {} \; + find $(DESTDIR)$(docdir) -name "*.jpg" -type f -exec rm -rf {} \; + find $(DESTDIR)$(docdir) -name "*.map" -type f -exec rm -rf {} \; + find $(DESTDIR)$(docdir) -name "*.md5" -type f -exec rm -rf {} \; + find $(DESTDIR)$(docdir) -name "*.png" -type f -exec rm -rf {} \; + find $(DESTDIR)$(docdir) -name "*.gif" -type f -exec rm -rf {} \; + find $(DESTDIR)$(docdir) -name "*.css" -type f -exec rm -rf {} \; + find $(DESTDIR)$(docdir) -name "*.js*" -type f -exec rm -rf {} \; + rm -rf $(DESTDIR)$(docdir)/sources + rm -rf $(DESTDIR)$(docdir)/HTML + rm -rf $(DESTDIR)$(docdir)/exemple + rm -rf $(DESTDIR)$(docdir)/*.in dev_docs: cp -fr $(srcdir)/KERNEL/* ./INPUT; \ diff --git a/idl/Makefile.am b/idl/Makefile.am index b046999d7..9ff37591d 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -235,14 +235,14 @@ SK.cc.hh: @PACO_IDL@ -I $(srcdir):@PACOPATH@/idl $^ omniORB4 0 install-exec-local: $(IDL_FILES:%=$(top_srcdir)/idl/%) - $(INSTALL) -d $(pkgpythondir) + $(INSTALL) -d $(DESTDIR)$(salomepythondir) ls $^ | while read file; do \ - $(OMNIORB_IDL) $(IDLPYFLAGS) -C$(pkgpythondir) $$file ; \ + $(OMNIORB_IDL) $(IDLPYFLAGS) -C$(DESTDIR)$(salomepythondir) $$file ; \ done # uninstall-local removes too much, but it works in distcheck uninstall-local: - rm -rf $(pkgpythondir)/* + rm -rf $(DESTDIR)$(salomepythondir)/* mostlyclean-local: -rm -f *.hh *.cc .depidl diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index f3139b6ec..0619ebfa0 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -132,6 +132,16 @@ module Engines */ readonly attribute string name ; + /*! + working directory of the %container + */ + readonly attribute string workingdir ; + + /*! + name of the %container log file (this has been set by the launcher) + */ + attribute string logfilename ; + /*! Shutdown the Container process. */ diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index c53d27a9c..8d2258cf5 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -54,6 +54,7 @@ struct MachineParameters boolean isMPI; string mpiImpl; string batch; + string workingdir; // PaCO specific informations string parallelLib; @@ -68,6 +69,21 @@ struct MachineParameters enum policy {P_FIRST,P_CYCL,P_BEST}; typedef policy ResPolicy; +/*! + Structure used for Salome Batch Job parameters +*/ +struct BatchParameters +{ + string batch_directory; // Where batch command will be launched + // and log files will be created + string expected_during_time; // Time for the batch + // has to be like this : hh:mm + string mem; // Minimum of memory needed + // has to be like : 32gb or 512mb + + long nb_proc; // Number of processors requested +}; + /*! \brief Interface of the %salomelauncher This interface is used for interaction with the unique instance of SalomeLauncher @@ -77,7 +93,7 @@ struct MachineParameters long submitSalomeJob( in string fileToExecute, in FilesList filesToExport, in FilesList filesToImport, - in long NumberOfProcessors, + in BatchParameters batch_params, in MachineParameters params ) raises (SALOME::SALOME_Exception); string querySalomeJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception); void deleteSalomeJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception); diff --git a/salome_adm/unix/SALOMEconfig.ref.in b/salome_adm/unix/SALOMEconfig.ref.in index 22372e97a..78688bd88 100644 --- a/salome_adm/unix/SALOMEconfig.ref.in +++ b/salome_adm/unix/SALOMEconfig.ref.in @@ -54,4 +54,21 @@ /* A path to a ssh-like command */ #define SSH "@SSH@" +// This is only to suppress warning messages with defines redefined (cause of omniORB that exports these names) +#ifdef PACKAGE_BUGREPORT +#undef PACKAGE_BUGREPORT +#endif +#ifdef PACKAGE_NAME +#undef PACKAGE_NAME +#endif +#ifdef PACKAGE_STRING +#undef PACKAGE_STRING +#endif +#ifdef PACKAGE_TARNAME +#undef PACKAGE_TARNAME +#endif +#ifdef PACKAGE_VERSION +#undef PACKAGE_VERSION +#endif + #endif diff --git a/salome_adm/unix/config_files/check_hdf5.m4 b/salome_adm/unix/config_files/check_hdf5.m4 index 4d200e8f3..9cc52b321 100644 --- a/salome_adm/unix/config_files/check_hdf5.m4 +++ b/salome_adm/unix/config_files/check_hdf5.m4 @@ -42,6 +42,7 @@ hdf5_ok=no LOCAL_INCLUDES="" LOCAL_LIBS="" +LOCAL_RLIBS="" if test -z $HDF5HOME then @@ -53,6 +54,7 @@ else LOCAL_LIBS="" else LOCAL_LIBS="-L$HDF5HOME/lib" + LOCAL_RLIBS="-R$HDF5HOME/lib" fi fi @@ -79,8 +81,8 @@ fi if test "x$hdf5_ok" = "xyes" then HDF5_INCLUDES="$LOCAL_INCLUDES" - HDF5_LIBS="$LOCAL_LIBS -lhdf5" - HDF5_MT_LIBS="$LOCAL_LIBS -lhdf5" + HDF5_LIBS="$LOCAL_LIBS -lhdf5 $LOCAL_RLIBS" + HDF5_MT_LIBS="$LOCAL_LIBS -lhdf5 $LOCAL_RLIBS" fi AC_MSG_RESULT(for hdf5: $hdf5_ok) diff --git a/salome_adm/unix/config_files/check_omniorb.m4 b/salome_adm/unix/config_files/check_omniorb.m4 index f82428747..7818bc85f 100644 --- a/salome_adm/unix/config_files/check_omniorb.m4 +++ b/salome_adm/unix/config_files/check_omniorb.m4 @@ -17,7 +17,7 @@ AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_PATH_PROG(OMNIORB_IDL, omniidl) -if test "xOMNIORB_IDL" = "x" +if test "x$OMNIORB_IDL" = "x" then omniORB_ok=no AC_MSG_RESULT(omniORB binaries not in PATH variable) @@ -101,15 +101,15 @@ then fi -dnl omniORB_ok=yes - if test "x$omniORB_ok" = "xyes" then if test "x$OMNIORB_LIB" = "x/usr/lib" then OMNIORB_LDFLAGS="" + OMNIORB_RFLAGS="" else OMNIORB_LDFLAGS="-L$OMNIORB_LIB" + OMNIORB_RFLAGS="-R$OMNIORB_LIB" fi LIBS_old=$LIBS @@ -153,6 +153,7 @@ then OMNIORB_LIBS="$OMNIORB_LIBS -lCOS${OMNIORB_VERSION}" OMNIORB_LIBS="$OMNIORB_LIBS -lCOSDynamic${OMNIORB_VERSION}" OMNIORB_LIBS="$OMNIORB_LIBS -lomnithread" + OMNIORB_LIBS="$OMNIORB_LIBS ${OMNIORB_RFLAGS}" if test $OMNIORB_VERSION = 3 ; then OMNIORB_LIBS="$OMNIORB_LIBS -ltcpwrapGK" fi @@ -188,7 +189,7 @@ if test "x$omniORB_ok" = "xyes" then OMNIORB_IDLCXXFLAGS="-Wba -nf -I${OMNIORB_ROOT}/idl" - OMNIORB_IDLPYFLAGS_1='-bpython -p ${top_srcdir}/salome_adm/unix' + OMNIORB_IDLPYFLAGS_1='-bpython' OMNIORB_IDLPYFLAGS_2=" -I${OMNIORB_ROOT}/idl" OMNIORB_IDLPYFLAGS=${OMNIORB_IDLPYFLAGS_1}${OMNIORB_IDLPYFLAGS_2} diff --git a/salome_adm/unix/config_files/check_swig.m4 b/salome_adm/unix/config_files/check_swig.m4 index 019755067..08668fb56 100644 --- a/salome_adm/unix/config_files/check_swig.m4 +++ b/salome_adm/unix/config_files/check_swig.m4 @@ -24,6 +24,7 @@ AC_DEFUN([CHECK_SWIG],[ AC_REQUIRE([CHECK_PYTHON])dnl swig_ok=yes +numpy_ok=no AC_ARG_WITH(swig, [AC_HELP_STRING([--with-swig=EXEC],[swig executable])], @@ -59,7 +60,7 @@ fi numpydir=`$PYTHON -c "import numpy;print numpy.get_include()" 2>/dev/null` if test -d "$numpydir"; then - SWIG_FLAGS="$SWIG_FLAGS -DWITH_NUMPY" + numpy_ok=yes PYTHON_INCLUDES="$PYTHON_INCLUDES -I$numpydir" AC_DEFINE([WITH_NUMPY], [], [Python has numpy extension]) fi diff --git a/salome_adm/unix/make_common_starter.am b/salome_adm/unix/make_common_starter.am index 258e057af..f54d8f4f2 100644 --- a/salome_adm/unix/make_common_starter.am +++ b/salome_adm/unix/make_common_starter.am @@ -7,16 +7,19 @@ # # Standard directory for installation -salomeincludedir = $(includedir)/@PACKAGE@ -libdir = $(prefix)/lib@LIB_LOCATION_SUFFIX@/@PACKAGE@ -bindir = $(prefix)/bin/@PACKAGE@ +salomeincludedir = $(includedir)/salome +libdir = $(prefix)/lib@LIB_LOCATION_SUFFIX@/salome +bindir = $(prefix)/bin/salome salomescriptdir = $(bindir) +salomepythondir = $(pythondir)/salome +salomepyexecdir = $(pyexecdir)/salome + # Directory for installing idl files -salomeidldir = $(prefix)/idl/@PACKAGE@ +salomeidldir = $(prefix)/idl/salome # Directory for installing resource files -salomeresdir = $(prefix)/share/@PACKAGE@/resources/@MODULE_NAME@ +salomeresdir = $(prefix)/share/salome/resources/@MODULE_NAME@ # Directories for installing admin files salomeadmdir = $(prefix)/salome_adm @@ -25,7 +28,7 @@ salomem4dir = $(salomeadmdir)/unix/config_files salome4deprdir = $(salomeadmdir)/unix/config_files/DEPRECATED # Shared modules installation directory -sharedpkgpythondir =$(pkgpythondir)/shared_modules +sharedpkgpythondir =$(salomepythondir)/shared_modules # Documentation directory -docdir = $(datadir)/doc/@PACKAGE@ +docdir = $(datadir)/doc/salome diff --git a/src/Batch/Batch_APIInternalFailureException.hxx b/src/Batch/Batch_APIInternalFailureException.hxx index 0494a55ed..cb8bb1be8 100644 --- a/src/Batch/Batch_APIInternalFailureException.hxx +++ b/src/Batch/Batch_APIInternalFailureException.hxx @@ -37,7 +37,7 @@ namespace Batch { - class BASICS_EXPORT APIInternalFailureException : public GenericException + class BATCH_EXPORT APIInternalFailureException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_BatchManager.hxx b/src/Batch/Batch_BatchManager.hxx index 24562d3ee..669c161bc 100644 --- a/src/Batch/Batch_BatchManager.hxx +++ b/src/Batch/Batch_BatchManager.hxx @@ -43,7 +43,7 @@ namespace Batch { class Job; class JobId; class JobInfo; - class BASICS_EXPORT FactBatchManager; + class BATCH_EXPORT FactBatchManager; class BatchManager { diff --git a/src/Batch/Batch_BatchManagerCatalog.hxx b/src/Batch/Batch_BatchManagerCatalog.hxx index ceead8a2f..d19ae24e3 100644 --- a/src/Batch/Batch_BatchManagerCatalog.hxx +++ b/src/Batch/Batch_BatchManagerCatalog.hxx @@ -39,7 +39,7 @@ namespace Batch { class FactBatchManager; - class BASICS_EXPORT BatchManagerCatalog + class BATCH_EXPORT BatchManagerCatalog { public: // Constructeur diff --git a/src/Batch/Batch_BoolType.hxx b/src/Batch/Batch_BoolType.hxx index bf5842d47..f25c24c5f 100644 --- a/src/Batch/Batch_BoolType.hxx +++ b/src/Batch/Batch_BoolType.hxx @@ -36,7 +36,7 @@ namespace Batch { - class BASICS_EXPORT BoolType : public GenericType + class BATCH_EXPORT BoolType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_CharType.hxx b/src/Batch/Batch_CharType.hxx index 3087b86b0..abac3be3a 100644 --- a/src/Batch/Batch_CharType.hxx +++ b/src/Batch/Batch_CharType.hxx @@ -36,7 +36,7 @@ namespace Batch { - class BASICS_EXPORT CharType : public GenericType + class BATCH_EXPORT CharType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_ConnexionFailureException.hxx b/src/Batch/Batch_ConnexionFailureException.hxx index 50682ad41..0d3a47e86 100644 --- a/src/Batch/Batch_ConnexionFailureException.hxx +++ b/src/Batch/Batch_ConnexionFailureException.hxx @@ -37,7 +37,7 @@ namespace Batch { - class BASICS_EXPORT ConnexionFailureException : public GenericException + class BATCH_EXPORT ConnexionFailureException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_Couple.hxx b/src/Batch/Batch_Couple.hxx index 187a9ddbf..9c0deed45 100644 --- a/src/Batch/Batch_Couple.hxx +++ b/src/Batch/Batch_Couple.hxx @@ -36,7 +36,7 @@ namespace Batch { - class BASICS_EXPORT Couple + class BATCH_EXPORT Couple { public: // Constructeur standard diff --git a/src/Batch/Batch_CoupleType.hxx b/src/Batch/Batch_CoupleType.hxx index 1951769b6..b7d323331 100644 --- a/src/Batch/Batch_CoupleType.hxx +++ b/src/Batch/Batch_CoupleType.hxx @@ -38,7 +38,7 @@ namespace Batch { - class BASICS_EXPORT CoupleType : public GenericType + class BATCH_EXPORT CoupleType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_Date.hxx b/src/Batch/Batch_Date.hxx index 7547d761e..ff7d37a6f 100644 --- a/src/Batch/Batch_Date.hxx +++ b/src/Batch/Batch_Date.hxx @@ -36,7 +36,7 @@ namespace Batch { - class BASICS_EXPORT Date + class BATCH_EXPORT Date { public: Date(const long l=0); diff --git a/src/Batch/Batch_DateType.hxx b/src/Batch/Batch_DateType.hxx index 6e03deeda..c7fef39a5 100644 --- a/src/Batch/Batch_DateType.hxx +++ b/src/Batch/Batch_DateType.hxx @@ -38,7 +38,7 @@ namespace Batch { - class BASICS_EXPORT DateType : public GenericType + class BATCH_EXPORT DateType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_Defines.hxx b/src/Batch/Batch_Defines.hxx index 3ec534c38..cd66ca5ff 100755 --- a/src/Batch/Batch_Defines.hxx +++ b/src/Batch/Batch_Defines.hxx @@ -27,13 +27,13 @@ #define _BATCH_Defines_HXX_ #ifdef WNT -# ifdef BASICS_EXPORTS -# define BASICS_EXPORT __declspec( dllexport ) +# ifdef BATCH_EXPORTS +# define BATCH_EXPORT __declspec( dllexport ) # else -# define BASICS_EXPORT __declspec( dllimport ) +# define BATCH_EXPORT __declspec( dllimport ) # endif #else -# define BASICS_EXPORT +# define BATCH_EXPORT #endif #endif diff --git a/src/Batch/Batch_FactBatchManager.hxx b/src/Batch/Batch_FactBatchManager.hxx index 03695a703..3a229be30 100644 --- a/src/Batch/Batch_FactBatchManager.hxx +++ b/src/Batch/Batch_FactBatchManager.hxx @@ -38,7 +38,7 @@ namespace Batch { class BatchManager; - class BASICS_EXPORT FactBatchManager + class BATCH_EXPORT FactBatchManager { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_GenericException.hxx b/src/Batch/Batch_GenericException.hxx index b4e48f7ed..89f79f49a 100644 --- a/src/Batch/Batch_GenericException.hxx +++ b/src/Batch/Batch_GenericException.hxx @@ -37,7 +37,7 @@ namespace Batch { - class BASICS_EXPORT GenericException + class BATCH_EXPORT GenericException { public: const std::string type; // la nature de l'exception diff --git a/src/Batch/Batch_GenericType.hxx b/src/Batch/Batch_GenericType.hxx index d14a59fd6..c5d7faf83 100644 --- a/src/Batch/Batch_GenericType.hxx +++ b/src/Batch/Batch_GenericType.hxx @@ -37,7 +37,7 @@ namespace Batch { - class BASICS_EXPORT GenericType + class BATCH_EXPORT GenericType { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_IntType.hxx b/src/Batch/Batch_IntType.hxx index 88846a2b3..3808c9514 100644 --- a/src/Batch/Batch_IntType.hxx +++ b/src/Batch/Batch_IntType.hxx @@ -36,7 +36,7 @@ namespace Batch { - class BASICS_EXPORT IntType : public GenericType + class BATCH_EXPORT IntType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_InvalidArgumentException.hxx b/src/Batch/Batch_InvalidArgumentException.hxx index 6f7283e28..8ca04c190 100644 --- a/src/Batch/Batch_InvalidArgumentException.hxx +++ b/src/Batch/Batch_InvalidArgumentException.hxx @@ -38,7 +38,7 @@ namespace Batch { - class BASICS_EXPORT InvalidArgumentException : public GenericException + class BATCH_EXPORT InvalidArgumentException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_InvalidKeyException.hxx b/src/Batch/Batch_InvalidKeyException.hxx index 0631bcbf7..7c9c7022a 100644 --- a/src/Batch/Batch_InvalidKeyException.hxx +++ b/src/Batch/Batch_InvalidKeyException.hxx @@ -38,7 +38,7 @@ namespace Batch { - class BASICS_EXPORT InvalidKeyException : public GenericException + class BATCH_EXPORT InvalidKeyException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_Job.hxx b/src/Batch/Batch_Job.hxx index 115cc3a40..fabecde27 100644 --- a/src/Batch/Batch_Job.hxx +++ b/src/Batch/Batch_Job.hxx @@ -37,7 +37,7 @@ namespace Batch { - class BASICS_EXPORT Job + class BATCH_EXPORT Job { public: // Constructeurs et destructeur diff --git a/src/Batch/Batch_JobId.hxx b/src/Batch/Batch_JobId.hxx index 5a21926ac..9ae57d183 100644 --- a/src/Batch/Batch_JobId.hxx +++ b/src/Batch/Batch_JobId.hxx @@ -39,7 +39,7 @@ namespace Batch { class BatchManager; - class BASICS_EXPORT JobId + class BATCH_EXPORT JobId { friend class BatchManager; diff --git a/src/Batch/Batch_JobInfo.hxx b/src/Batch/Batch_JobInfo.hxx index 9b54df617..bb9c50b12 100644 --- a/src/Batch/Batch_JobInfo.hxx +++ b/src/Batch/Batch_JobInfo.hxx @@ -41,7 +41,7 @@ using namespace std; namespace Batch { - class BASICS_EXPORT JobInfo + class BATCH_EXPORT JobInfo { public: // Constructeur standard et destructeur diff --git a/src/Batch/Batch_ListIsFullException.hxx b/src/Batch/Batch_ListIsFullException.hxx index 885af69ce..0525ba449 100644 --- a/src/Batch/Batch_ListIsFullException.hxx +++ b/src/Batch/Batch_ListIsFullException.hxx @@ -35,7 +35,7 @@ namespace Batch { - class BASICS_EXPORT ListIsFullException : public GenericException + class BATCH_EXPORT ListIsFullException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_LongType.hxx b/src/Batch/Batch_LongType.hxx index cf9e7f02a..3970ae0e7 100644 --- a/src/Batch/Batch_LongType.hxx +++ b/src/Batch/Batch_LongType.hxx @@ -36,7 +36,7 @@ namespace Batch { - class BASICS_EXPORT LongType : public GenericType + class BATCH_EXPORT LongType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_MapKey.hxx b/src/Batch/Batch_MapKey.hxx index ec99262da..43e943f8b 100644 --- a/src/Batch/Batch_MapKey.hxx +++ b/src/Batch/Batch_MapKey.hxx @@ -39,7 +39,7 @@ namespace Batch { // une classe privee pour les differents types // ces types ne peuvent pas etre redefinis - class BASICS_EXPORT MapKey : public std::string + class BATCH_EXPORT MapKey : public std::string { private: friend class Parametre; // seule la classe Parametre peut creer des MapKey diff --git a/src/Batch/Batch_NotYetImplementedException.hxx b/src/Batch/Batch_NotYetImplementedException.hxx index 4f324b655..2ca75a1e1 100644 --- a/src/Batch/Batch_NotYetImplementedException.hxx +++ b/src/Batch/Batch_NotYetImplementedException.hxx @@ -38,7 +38,7 @@ using namespace std; namespace Batch { - class BASICS_EXPORT NotYetImplementedException : public GenericException + class BATCH_EXPORT NotYetImplementedException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_Parametre.hxx b/src/Batch/Batch_Parametre.hxx index 28d8c9810..7efc677c3 100644 --- a/src/Batch/Batch_Parametre.hxx +++ b/src/Batch/Batch_Parametre.hxx @@ -49,7 +49,7 @@ using namespace std; namespace Batch { - class BASICS_EXPORT Parametre : public map< string, Versatile > + class BATCH_EXPORT Parametre : public map< string, Versatile > { public: // Constructeur standard diff --git a/src/Batch/Batch_PyVersatile.hxx b/src/Batch/Batch_PyVersatile.hxx index fe8f6f165..8a26209ad 100644 --- a/src/Batch/Batch_PyVersatile.hxx +++ b/src/Batch/Batch_PyVersatile.hxx @@ -42,7 +42,7 @@ using namespace std; namespace Batch { - class BASICS_EXPORT PyVersatile : public Versatile + class BATCH_EXPORT PyVersatile : public Versatile { public: // Constructeur a partir d'un objet Versatile diff --git a/src/Batch/Batch_RunTimeException.hxx b/src/Batch/Batch_RunTimeException.hxx index 0553f9522..fe1e168d4 100644 --- a/src/Batch/Batch_RunTimeException.hxx +++ b/src/Batch/Batch_RunTimeException.hxx @@ -37,7 +37,7 @@ namespace Batch { - class BASICS_EXPORT RunTimeException : public GenericException + class BATCH_EXPORT RunTimeException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_StringType.hxx b/src/Batch/Batch_StringType.hxx index 58033dc64..510924e9b 100644 --- a/src/Batch/Batch_StringType.hxx +++ b/src/Batch/Batch_StringType.hxx @@ -36,7 +36,7 @@ namespace Batch { - class BASICS_EXPORT StringType : public GenericType + class BATCH_EXPORT StringType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_TypeMismatchException.hxx b/src/Batch/Batch_TypeMismatchException.hxx index dce638c2d..b231060dc 100644 --- a/src/Batch/Batch_TypeMismatchException.hxx +++ b/src/Batch/Batch_TypeMismatchException.hxx @@ -36,7 +36,7 @@ namespace Batch { - class BASICS_EXPORT TypeMismatchException : public GenericException + class BATCH_EXPORT TypeMismatchException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_Versatile.hxx b/src/Batch/Batch_Versatile.hxx index 79c3de35d..c7b6f3bf6 100644 --- a/src/Batch/Batch_Versatile.hxx +++ b/src/Batch/Batch_Versatile.hxx @@ -55,7 +55,7 @@ namespace Batch { int maxelem; // le nombre d'elements autorises } TypeParam; - class BASICS_EXPORT Versatile : public std::list< GenericType * > + class BATCH_EXPORT Versatile : public std::list< GenericType * > { public: // Constructeur standard et destructeur diff --git a/src/Batch_SWIG/Makefile.am b/src/Batch_SWIG/Makefile.am index 71154d513..9fceccda1 100644 --- a/src/Batch_SWIG/Makefile.am +++ b/src/Batch_SWIG/Makefile.am @@ -55,8 +55,8 @@ BUILT_SOURCES = swig_wrap.cpp SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../Batch SWIG_SOURCES = libBatch_Swig.i libBatch_Swig_exception.i libBatch_Swig_typemap.i -pkgpython_PYTHON = libBatch_Swig.py -pkgpyexec_LTLIBRARIES = _libBatch_Swig.la +salomepython_PYTHON = libBatch_Swig.py +salomepyexec_LTLIBRARIES = _libBatch_Swig.la _libBatch_Swig_la_SOURCES = $(BUILT_SOURCES) $(SWIG_SOURCES) _libBatch_Swig_la_CPPFLAGS = @PYTHON_INCLUDES@ -I$(srcdir) -I$(srcdir)/../Batch _libBatch_Swig_la_LDFLAGS = -module @@ -83,4 +83,4 @@ CLEANFILES = swig_wrap.cpp dist_salomescript_SCRIPTS = Batch_test.py # You don't need to specify libBatch_Swig.py. It is automatically -# installed by means of the swig target pkgpython_PYTHON. +# installed by means of the swig target salomepython_PYTHON. diff --git a/src/Batch_SWIG/libBatch_Swig.i b/src/Batch_SWIG/libBatch_Swig.i index f5b5e791a..b3098f16c 100644 --- a/src/Batch_SWIG/libBatch_Swig.i +++ b/src/Batch_SWIG/libBatch_Swig.i @@ -48,6 +48,7 @@ %include libBatch_Swig_exception.i %{ +#include "Batch_Defines.hxx" #include "Batch_Job.hxx" #include "Batch_JobId.hxx" #include "Batch_JobInfo.hxx" @@ -58,13 +59,14 @@ %} /* Les classes exportees en Python */ -%include Batch_Job.hxx -%include Batch_JobId.hxx -%include Batch_JobInfo.hxx +%include "Batch_Defines.hxx" +%include "Batch_Job.hxx" +%include "Batch_JobId.hxx" +%include "Batch_JobInfo.hxx" -%include Batch_BatchManager.hxx -%include Batch_BatchManagerCatalog.hxx -%include Batch_FactBatchManager.hxx +%include "Batch_BatchManager.hxx" +%include "Batch_BatchManagerCatalog.hxx" +%include "Batch_FactBatchManager.hxx" diff --git a/src/Communication_SWIG/Makefile.am b/src/Communication_SWIG/Makefile.am index 30907c8d4..9dd1946a5 100644 --- a/src/Communication_SWIG/Makefile.am +++ b/src/Communication_SWIG/Makefile.am @@ -56,8 +56,8 @@ SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../Communication SWIG_SOURCES = libSALOME_Comm.i -pkgpython_PYTHON = libSALOME_Comm.py -pkgpyexec_LTLIBRARIES = _libSALOME_Comm.la +salomepython_PYTHON = libSALOME_Comm.py +salomepyexec_LTLIBRARIES = _libSALOME_Comm.la _libSALOME_Comm_la_SOURCES = $(BUILT_SOURCES) $(SWIG_SOURCES) _libSALOME_Comm_la_CPPFLAGS =\ @PYTHON_INCLUDES@ \ @@ -97,4 +97,4 @@ CLEANFILES = swig_wrap.cpp # (see LifeCycleCORBA_SWIG for an example) # It's not needed to specify libSALOME_Comm.py. It is -# automaticaly installed through the swig target pkgpython_PYTHON. +# automaticaly installed through the swig target salomepython_PYTHON. diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index cdbef093f..cfeeefc9b 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -63,7 +63,7 @@ bool Engines_Component_i::_isMultiInstance = false; */ //============================================================================= -Engines_Component_i::Engines_Component_i() +Engines_Component_i::Engines_Component_i():_myConnexionToRegistry(0), _notifSupplier(0) { //ASSERT(0); MESSAGE("Default Constructor, not for normal use..."); @@ -91,6 +91,7 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, _instanceName(instanceName), _interfaceName(interfaceName), _myConnexionToRegistry(0), + _notifSupplier(0), _ThreadId(0) , _ThreadCpuUsed(0) , _Executed(false) , @@ -137,6 +138,7 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, _instanceName(instanceName), _interfaceName(interfaceName), _myConnexionToRegistry(0), + _notifSupplier(0), _ThreadId(0) , _ThreadCpuUsed(0) , _Executed(false) , @@ -164,6 +166,8 @@ Engines_Component_i::~Engines_Component_i() { MESSAGE("Component destructor"); Engines_Container_i::decInstanceCnt(_interfaceName); + if(_myConnexionToRegistry)delete _myConnexionToRegistry; + if(_notifSupplier)delete _notifSupplier; } //============================================================================= diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 2f5692fdc..41e2b5b61 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -241,6 +241,35 @@ char* Engines_Container_i::name() return CORBA::string_dup(_containerName.c_str()) ; } +//============================================================================= +/*! + * CORBA attribute: Container working directory + */ +//============================================================================= + +char* Engines_Container_i::workingdir() +{ + char wd[256]; + getcwd (wd,256); + return CORBA::string_dup(wd) ; +} + +//============================================================================= +/*! + * CORBA attribute: Container log file name + */ +//============================================================================= + +char* Engines_Container_i::logfilename() +{ + return CORBA::string_dup(_logfilename.c_str()) ; +} + +void Engines_Container_i::logfilename(const char* name) +{ + _logfilename=name; +} + //============================================================================= /*! * CORBA method: Get the hostName of the Container (without domain extensions) @@ -336,8 +365,8 @@ Engines_Container_i::load_component_Library(const char* componentName) _numInstanceMutex.lock(); // lock to be alone // (see decInstanceCnt, finalize_removal)) - if (_toRemove_map[impl_name]) _toRemove_map.erase(impl_name); - if (_library_map[impl_name]) + if (_toRemove_map.count(impl_name) != 0) _toRemove_map.erase(impl_name); + if (_library_map.count(impl_name) != 0) { MESSAGE("Library " << impl_name << " already loaded"); _numInstanceMutex.unlock(); @@ -358,13 +387,6 @@ Engines_Container_i::load_component_Library(const char* componentName) _numInstanceMutex.unlock(); return true; } - else - { - INFOS( "Can't load shared library: " << impl_name ); -#ifndef WNT - INFOS("error dlopen: " << dlerror()); -#endif - } _numInstanceMutex.unlock(); // --- try import Python component @@ -375,7 +397,7 @@ Engines_Container_i::load_component_Library(const char* componentName) INFOS("Supervision Container does not support Python Component Engines"); return false; } - if (_library_map[aCompName]) + if (_library_map.count(aCompName) != 0) { return true; // Python Component, already imported } @@ -389,6 +411,7 @@ Engines_Container_i::load_component_Library(const char* componentName) "import_component", "s",componentName); int ret= PyInt_AsLong(result); + Py_XDECREF(result); SCRUTE(ret); Py_RELEASE_NEW_THREAD; @@ -401,6 +424,9 @@ Engines_Container_i::load_component_Library(const char* componentName) return true; } } + INFOS( "Impossible to load component: " << componentName ); + INFOS( "Can't load shared library: " << impl_name ); + INFOS( "Can't import Python module: " << componentName ); return false; } @@ -429,7 +455,7 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, Engines::Component_var iobject = Engines::Component::_nil() ; string aCompName = genericRegisterName; - if (_library_map[aCompName]) // Python component + if (_library_map.count(aCompName) != 0) // Python component { if (_isSupervContainer) { @@ -478,14 +504,14 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, #else string impl_name = genericRegisterName +string("Engine.dll"); #endif - void* handle = _library_map[impl_name]; - if ( !handle ) + if (_library_map.count(impl_name) == 0) { - INFOS("shared library " << impl_name <<"must be loaded before instance"); + INFOS("shared library " << impl_name <<" must be loaded before creating instance"); return Engines::Component::_nil() ; } else { + void* handle = _library_map[impl_name]; iobject = createInstance(genericRegisterName, handle, studyId); @@ -735,16 +761,16 @@ Engines_Container_i::find_or_create_instance(string genericRegisterName, { string aGenRegisterName = genericRegisterName; string impl_name = componentLibraryName; - void* handle = _library_map[impl_name]; - if ( !handle ) + if (_library_map.count(impl_name) == 0) { - INFOS("shared library " << impl_name <<"must be loaded before instance"); + INFOS("shared library " << impl_name <<" must be loaded before creating instance"); return Engines::Component::_nil() ; } else { // --- find a registered instance in naming service, or create + void* handle = _library_map[impl_name]; string component_registerBase = _containerName + "/" + aGenRegisterName; Engines::Component_var iobject = Engines::Component::_nil() ; diff --git a/src/Container/Makefile.am b/src/Container/Makefile.am index 409e9e0bb..a7cbd05da 100644 --- a/src/Container/Makefile.am +++ b/src/Container/Makefile.am @@ -91,9 +91,8 @@ COMMON_LIBS =\ ../Batch/libSalomeBatch.la \ $(top_builddir)/idl/libSalomeIDLKernel.la\ @MPI_LIBS@ \ - @CORBA_LIBS@ - -# @PYTHON_LIBS@ + @CORBA_LIBS@ \ + $(PYTHON_LIBS) # # =============================================================== @@ -118,7 +117,6 @@ libSalomeContainer_la_LDFLAGS =\ @LDEXPDYNFLAGS@ libSalomeContainer_la_LIBADD =\ - $(PYTHON_LIBS) \ $(COMMON_LIBS) if WITH_PACO_PARALLEL @@ -141,11 +139,12 @@ SALOME_Container_SOURCES =\ SALOME_Container_CPPFLAGS =\ $(COMMON_CPPFLAGS) -SALOME_Container_LDADD =\ +SALOME_Container_LDADD = \ libSalomeContainer.la \ - $(COMMON_LIBS) \ - ../Basics/libSALOMEBasics.la \ - ../Batch/libSalomeBatch.la + $(HDF5_LIBS) \ + $(MPI_LIBS) \ + $(CORBA_LIBS) \ + $(PYTHON_LIBS) SALOME_Container_LDFLAGS =\ -Xlinker -export-dynamic @@ -158,5 +157,7 @@ TestSalome_file_CPPFLAGS =\ TestSalome_file_LDADD =\ libSalomeContainer.la \ - $(COMMON_LIBS) \ - ../Basics/libSALOMEBasics.la + $(HDF5_LIBS) \ + $(MPI_LIBS) \ + $(CORBA_LIBS) \ + $(PYTHON_LIBS) diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 9e3ee1383..03234c307 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -29,6 +29,8 @@ #ifndef _SALOME_COMPONENT_I_HXX_ #define _SALOME_COMPONENT_I_HXX_ +#include + #include #include @@ -40,7 +42,6 @@ #include #include #include -#include #include CORBA_SERVER_HEADER(SALOME_Component) #include "NOTIFICATION.hxx" #include "Salome_file_i.hxx" diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index 385b59e16..51bc4ca8c 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -195,9 +195,16 @@ int main(int argc, char* argv[]) HandleServerSideSignals(orb); - PyGILState_STATE gstate = PyGILState_Ensure(); - //Delete python container that destroy orb from python (pyCont._orb.destroy()) - Py_Finalize(); + if (!isSupervContainer) + { + PyGILState_STATE gstate = PyGILState_Ensure(); + //Delete python container that destroy orb from python (pyCont._orb.destroy()) + Py_Finalize(); + } + else + { + orb->destroy(); + } } catch(CORBA::SystemException&) { diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 3a39df34d..c7881e013 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -280,6 +280,10 @@ StartContainer(const Engines::MachineParameters& params, //Engines::Container_var cont=Engines::Container::_narrow(obj); } + //redirect stdout and stderr in a file + string logFilename="/tmp/"+_NS->ContainerName(params)+"_"+GetHostname()+"_"+getenv( "USER" )+".log" ; + command += " > " + logFilename + " 2>&1 &"; + // launch container with a system call int status=system(command.c_str()); if (status == -1){ @@ -310,7 +314,16 @@ StartContainer(const Engines::MachineParameters& params, } if ( CORBA::is_nil(ret) ) - MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed"); + { + MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed"); + } + else + { + logFilename=":"+logFilename; + logFilename="@"+GetHostname()+logFilename; + logFilename=getenv( "USER" )+logFilename; + ret->logfilename(logFilename.c_str()); + } return ret; } diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index 843fa794f..1694bc79d 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -141,10 +141,10 @@ class SALOME_ContainerPy_i (Engines__POA.Container): self._numInstance = self._numInstance +1 instanceName = nameToRegister + "_inst_" + `self._numInstance` - component=__import__(componentName) - factory=getattr(component,componentName) - comp_i=factory(self._orb, self._poa, self._this(), self._containerName, - instanceName, nameToRegister) + component=__import__(componentName) + factory=getattr(component,componentName) + comp_i=factory(self._orb, self._poa, self._this(), self._containerName, + instanceName, nameToRegister) MESSAGE( "SALOME_ContainerPy_i::instance : component created") comp_o = comp_i._this() @@ -172,7 +172,7 @@ class SALOME_ContainerPy_i (Engines__POA.Container): ret=0 try: if verbose(): print "try import ",componentName - __import__(componentName) + module=__import__(componentName) if verbose(): print "import ",componentName," successful" ret=1 except: diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index f39a54c4b..153b381f8 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -83,6 +83,10 @@ public: virtual void ping(); char* name(); + char* workingdir(); + char* logfilename(); + void logfilename(const char* name); + virtual void Shutdown(); char* getHostName(); CORBA::Long getPID(); @@ -125,6 +129,7 @@ protected: SALOME_NamingService *_NS ; std::string _library_path; std::string _containerName; + std::string _logfilename; CORBA::ORB_var _orb; PortableServer::POA_var _poa; PortableServer::ObjectId * _id ; diff --git a/src/DF/Makefile.am b/src/DF/Makefile.am index 00dabed07..f06c02a41 100644 --- a/src/DF/Makefile.am +++ b/src/DF/Makefile.am @@ -51,15 +51,10 @@ COMMON_CPPFLAGS=\ @HDF5_INCLUDES@ \ @BOOST_CPPFLAGS@ -# This flag is used to resolve the dependencies of OCC libraries. -LDXMUFLAGS = -L/usr/X11R6/lib@LIB_LOCATION_SUFFIX@ -lXmu - # This local variable defines the list of dependant libraries common to all target in this package. COMMON_LIBS =\ ../HDFPersist/libSalomeHDFPersist.la \ - @HDF5_LIBS@ \ - $(LDXMUFLAGS) - + @HDF5_LIBS@ # # =============================================================== @@ -95,5 +90,6 @@ libDF_la_LIBADD = $(COMMON_LIBS) bin_PROGRAMS = testDF testDF_SOURCES = testDF.cxx testDF_CPPFLAGS = $(COMMON_CPPFLAGS) -testDF_LDADD = libDF.la $(COMMON_LIBS) +testDF_LDADD = ./libDF.la \ + $(HDF5_LIBS) diff --git a/src/DSC/DSC_Basic/DSC_i.cxx b/src/DSC/DSC_Basic/DSC_i.cxx index 41b5adcea..bf67a554c 100644 --- a/src/DSC/DSC_Basic/DSC_i.cxx +++ b/src/DSC/DSC_Basic/DSC_i.cxx @@ -37,7 +37,9 @@ Engines_DSC_i(CORBA::ORB_ptr orb, instanceName, interfaceName) { - std::cout << "--Engines_DSC_i: MARK 1 --" << instanceName << "----" << std::endl; +#ifdef _DEBUG_ + std::cerr << "--Engines_DSC_i: MARK 1 --" << instanceName << "----" << std::endl; +#endif } Engines_DSC_i::~Engines_DSC_i() {} diff --git a/src/DSC/DSC_Basic/DSC_interface.cxx b/src/DSC/DSC_Basic/DSC_interface.cxx index b32d69bfd..399a62c22 100644 --- a/src/DSC/DSC_Basic/DSC_interface.cxx +++ b/src/DSC/DSC_Basic/DSC_interface.cxx @@ -28,7 +28,13 @@ Engines_DSC_interface::Engines_DSC_interface() {} -Engines_DSC_interface::~Engines_DSC_interface() {} +Engines_DSC_interface::~Engines_DSC_interface() +{ + my_ports_it = my_ports.begin(); + for(;my_ports_it != my_ports.end();my_ports_it++) + delete my_ports_it->second; + +} void Engines_DSC_interface::add_provides_port(Ports::Port_ptr ref, diff --git a/src/DSC/DSC_Basic/DSC_interface.hxx b/src/DSC/DSC_Basic/DSC_interface.hxx index 525843110..5bf5712d2 100644 --- a/src/DSC/DSC_Basic/DSC_interface.hxx +++ b/src/DSC/DSC_Basic/DSC_interface.hxx @@ -164,9 +164,9 @@ protected: std::string repository_id; // Specifique aux provides port; - Ports::Port_ptr provides_port_ref; + Ports::Port_var provides_port_ref; - Ports::PortProperties_ptr port_prop; + Ports::PortProperties_var port_prop; }; typedef std::map ports; diff --git a/src/DSC/DSC_Python/Makefile.am b/src/DSC/DSC_Python/Makefile.am index a40629e79..d4f0d8e69 100644 --- a/src/DSC/DSC_Python/Makefile.am +++ b/src/DSC/DSC_Python/Makefile.am @@ -57,9 +57,9 @@ COMMON_LIBS = @CORBA_LIBS@ # AM_CFLAGS = -fexceptions -pkgpython_PYTHON = calcium.py dsccalcium.py -pkgpyexec_LTLIBRARIES = _calcium.la -MY_SWIG_FLAGS= $(SWIG_FLAGS) -noexcept +salomepython_PYTHON = calcium.py dsccalcium.py +salomepyexec_LTLIBRARIES = _calcium.la +MY_SWIG_FLAGS= $(SWIG_FLAGS) -noexcept -I$(top_srcdir)/src/DSC/DSC_User/Datastream/Calcium SWIG_SRC=calcium.i _calcium_la_SOURCES = calcium_wrap.cpp _calcium_la_LDFLAGS = -module @@ -72,6 +72,8 @@ _calcium_la_LIBADD = ../DSC_User/Datastream/Calcium/libCalciumC.la \ _calcium_la_CXXFLAGS = $(PYTHON_INCLUDES) $(COMMON_CPPFLAGS) +EXTRA_DIST=calcium_wrap.cpp calcium.i + calcium_wrap.cpp calcium.py:calcium.i $(SWIG) $(MY_SWIG_FLAGS) -o calcium_wrap.cpp $< diff --git a/src/DSC/DSC_Python/calcium.i b/src/DSC/DSC_Python/calcium.i index 3d093153c..dddf3aa06 100644 --- a/src/DSC/DSC_Python/calcium.i +++ b/src/DSC/DSC_Python/calcium.i @@ -5,7 +5,7 @@ %module(docstring=DOCSTRING) calcium -%feature("autodoc", "0"); +%feature("autodoc", "1"); %{ //C++ Includes @@ -13,6 +13,7 @@ #include #include #include +#include #include //--- from omniORBpy.h (not present on Debian Sarge packages) @@ -30,13 +31,15 @@ struct omniORBpyAPI { // Raises BAD_PARAM if the Python object is not an object reference. // If is true, caller holds the Python interpreter lock. - - omniORBpyAPI(); - // Constructor for the singleton. Sets up the function pointers. + PyObject* (*handleCxxSystemException)(const CORBA::SystemException& ex); + // Sets the Python exception state to reflect the given C++ system + // exception. Always returns NULL. The caller must hold the Python + // interpreter lock. }; omniORBpyAPI* api; + %} %init @@ -59,13 +62,10 @@ struct omniORBpyAPI { Py_DECREF(pyapi); %} -%include "carrays.i" +%include + -%array_class(int, intArray); -%array_class(float, floatArray); -%array_class(double, doubleArray); -#ifdef WITH_NUMPY /* * Most of this code is borrowed from numpy distribution * The following code originally appeared in enthought/kiva/agg/src/numeric.i, @@ -76,8 +76,12 @@ struct omniORBpyAPI { %{ +#ifdef WITH_NUMPY +/* With Numpy */ #include +typedef PyArrayObject ArrayObject; + /* Macros to extract array attributes. */ #define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a)) @@ -104,13 +108,52 @@ char* pytype_string(PyObject* py_obj) { return "unkown type"; } +/* +For documentation only : numpy typecodes + +enum NPY_TYPECHAR { NPY_BOOLLTR = '?', + NPY_BYTELTR = 'b', + NPY_UBYTELTR = 'B', + NPY_SHORTLTR = 'h', + NPY_USHORTLTR = 'H', + NPY_INTLTR = 'i', + NPY_UINTLTR = 'I', + NPY_LONGLTR = 'l', + NPY_ULONGLTR = 'L', + NPY_LONGLONGLTR = 'q', + NPY_ULONGLONGLTR = 'Q', + NPY_FLOATLTR = 'f', + NPY_DOUBLELTR = 'd', + NPY_LONGDOUBLELTR = 'g', + NPY_CFLOATLTR = 'F', + NPY_CDOUBLELTR = 'D', + NPY_CLONGDOUBLELTR = 'G', + NPY_OBJECTLTR = 'O', + NPY_STRINGLTR = 'S', + NPY_STRINGLTR2 = 'a', + NPY_UNICODELTR = 'U', + NPY_VOIDLTR = 'V', + NPY_CHARLTR = 'c', + + NPY_INTPLTR = 'p', + NPY_UINTPLTR = 'P', + + NPY_GENBOOLLTR ='b', + NPY_SIGNEDLTR = 'i', + NPY_UNSIGNEDLTR = 'u', + NPY_FLOATINGLTR = 'f', + NPY_COMPLEXLTR = 'c' +}; +*/ + /* Given a Numeric typecode, return a string describing the type. */ char* typecode_string(int typecode) { - char* type_names[20] = {"char","unsigned byte","byte","short", - "unsigned short","int","unsigned int","long", - "float","double","complex float","complex double", - "object","ntype","unkown"}; + char* type_names[] = {"bool","byte","unsigned byte","short", + "unsigned short","int","unsigned int","long","unsigned long", + "longlong","unsigned longlong", + "float","double","long double","complex float","complex double","complex long double", + "object","string","unicode","void","ntypes","notype","char","unkown"}; return type_names[typecode]; } @@ -320,18 +363,71 @@ int require_size(PyArrayObject* ary, int* size, int n) { return success; } +#else +/* Without Numpy */ +typedef PyObject ArrayObject; + +#endif %} -/* input typemap */ +%include "carrays.i" + +%array_class(int, intArray); +%array_class(float, floatArray); +%array_class(double, doubleArray); + +/* special struct to handle string arrays */ +%inline %{ +struct stringArray +{ + stringArray(int nelements,int size=0) { + nelem=nelements; + data= new char*[nelements]; + for(int i=0;idata; +%#else + SWIG_exception(SWIG_TypeError, "type* expected"); +%#endif } } %typemap(freearg) type* IN_ARRAY3 { @@ -345,19 +441,75 @@ TYPEMAP_IN3(double, PyArray_DOUBLE) #undef TYPEMAP_IN3 -%apply int* IN_ARRAY3 {int *val}; -%apply float* IN_ARRAY3 {float *val}; -%apply double* IN_ARRAY3 {double *val}; +%apply int* IN_ARRAY3 {int *eval}; +%apply float* IN_ARRAY3 {float *eval}; +%apply double* IN_ARRAY3 {double *eval}; + +/* Specific typemap for complex */ +%typemap(in) float* ecpval + (ArrayObject* array=NULL, int is_new_object) { + int size[1] = {-1}; + if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0)) == -1) + { +%#ifdef WITH_NUMPY + array = obj_to_array_contiguous_allow_conversion($input, PyArray_CFLOAT, &is_new_object); + if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail; + $1 = (float*) array->data; +%#else + SWIG_exception(SWIG_TypeError, "complex array expected"); +%#endif + } +} +%typemap(freearg) float* ecpval { + if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); +} +/* End of Specific typemap for complex */ + +/* array of strings on input */ +%typemap(in) char** eval + (ArrayObject* array=NULL, int is_new_object) { + int size[1] = {-1}; + stringArray* sarray; + if ((SWIG_ConvertPtr($input, (void **) &sarray, $descriptor(stringArray *),0)) == -1) + { +%#ifdef WITH_NUMPY + array = obj_to_array_contiguous_allow_conversion($input, PyArray_STRING, &is_new_object); + if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail; + $1 = (char**) malloc(array_size(array,0)*sizeof(char*)); + for(int i=0;idata + i* array->strides[0]; +%#else + SWIG_exception(SWIG_TypeError, "string array expected"); +%#endif + } + else + { + $1=sarray->data; + } +} + +%typemap(freearg) char** eval { + if (array$argnum) free($1); + if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); +} +/* End of array of strings on input */ -/* inplace typemaps */ +/* inplace typemaps + This typemap can be used for input/output array objects. + It accepts swig carray objects or numpy contiguous objects. +*/ %define TYPEMAP_INPLACE3(type,typecode) -%typemap(in) type* INPLACE_ARRAY3 (PyArrayObject* temp=NULL) { +%typemap(in) type* INPLACE_ARRAY3 (ArrayObject* temp=NULL) { if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0)) == -1) { +%#ifdef WITH_NUMPY temp = obj_to_array_no_conversion($input,typecode); if (!temp || !require_contiguous(temp)) SWIG_fail; $1 = (type*) temp->data; +%#else + SWIG_exception(SWIG_TypeError, "type* expected"); +%#endif } } %enddef @@ -372,82 +524,145 @@ TYPEMAP_INPLACE3(double, PyArray_DOUBLE) %apply float* INPLACE_ARRAY3 {float *lval}; %apply double* INPLACE_ARRAY3 {double *lval}; -#endif - -%typemap(in) CORBA::Boolean -{ - $1=(CORBA::Boolean)PyInt_AsLong($input); +/* typemap for complex inout */ +%typemap(in) float* lcpval + (ArrayObject* temp=NULL) { + if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0)) == -1) + { +%#ifdef WITH_NUMPY + temp = obj_to_array_no_conversion($input,PyArray_CFLOAT); + if (!temp || !require_contiguous(temp)) SWIG_fail; + $1 = (float*) temp->data; +%#else + SWIG_exception(SWIG_TypeError, "complex array expected"); +%#endif + } } +/* End of typemap for complex inout */ -%typemap(in) CORBA::ORB_ptr -{ - try { - CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); - $1 = CORBA::ORB::_narrow(obj); +/* typemap for array of strings on input/output */ +%typemap(in) char** lval + (ArrayObject* temp=NULL) { + stringArray* sarray; + if ((SWIG_ConvertPtr($input, (void **) &sarray, $descriptor(stringArray *) ,0)) == -1) + { +%#ifdef WITH_NUMPY + temp = obj_to_array_no_conversion($input,PyArray_STRING); + if (!temp || !require_contiguous(temp)) SWIG_fail; + $1 = (char**) malloc(array_size(temp,0)*sizeof(char*)); + for(int i=0;idata+i*temp->strides[0]; +%#else + SWIG_exception(SWIG_TypeError, "string array expected"); +%#endif } - catch (...) { - PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); + else + { + $1=sarray->data; } } +%typemap(freearg) char** lval { + if (temp$argnum) free($1); +} +/* End of typemap for array of strings on input/output */ -%typemap(in) PortableServer::POA_ptr +%typemap(in) CORBA::Boolean { - try { - CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); - $1 = PortableServer::POA::_narrow(obj); - } - catch (...) { - PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); - } + $1=(CORBA::Boolean)PyInt_AsLong($input); } -%typemap(in) Engines::Container_ptr +%define CORBAPTR(type) +%typemap(in) type##_ptr { - try { - CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); - $1 = Engines::Container::_narrow(obj); + Py_BEGIN_ALLOW_THREADS + try + { + CORBA::Object_var obj = api->pyObjRefToCxxObjRef($input,0); + $1 = type##::_narrow(obj); } - catch (...) { + catch(...) + { + Py_BLOCK_THREADS PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); } + Py_END_ALLOW_THREADS } +%typemap(freearg) type##_ptr { + CORBA::release($1); +} +%enddef + +CORBAPTR(CORBA::ORB) +CORBAPTR(Ports::PortProperties) +CORBAPTR(Ports::Port) +CORBAPTR(Engines::Container) +CORBAPTR(PortableServer::POA) -%typemap(in) Ports::Port_ptr +%typemap(out) Ports::Port_ptr { - try { - CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); - $1 = Ports::Port::_narrow(obj); - } - catch (...) { - PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); - } + $result = api->cxxObjRefToPyObjRef($1, 1); + //All output Ports::Port_ptr variables are duplicated by security. Need to release them for python . Explanation ?? + CORBA::release($1); } -%typemap(out) Ports::Port_ptr , Ports::PortProperties_ptr +%typemap(out) Ports::PortProperties_ptr, Engines::Salome_file_ptr { $result = api->cxxObjRefToPyObjRef($1, 1); } +%typemap(out) Engines::DSC::uses_port * +{ + $result = PyList_New($1->length()); + for (CORBA::ULong i=0; i < $1->length() ; i++) + PyList_SetItem($result,i,api->cxxObjRefToPyObjRef((*$1)[i], 1)); + //delete the copy (created by new) of uses port sequence + delete $1; +} + /* * Exception section */ // a general exception handler %exception { + Py_BEGIN_ALLOW_THREADS try { $action - } catch(Engines::DSC::PortNotDefined& _e) { + } + catch(Engines::DSC::PortNotDefined& _e) { + Py_BLOCK_THREADS PyErr_SetString(PyExc_ValueError,"Port not defined"); return NULL; - } catch(Engines::DSC::PortNotConnected& _e) { + } + catch(Engines::DSC::PortNotConnected& _e) { + Py_BLOCK_THREADS PyErr_SetString(PyExc_ValueError,"Port not connected"); return NULL; - } catch(Engines::DSC::BadPortType& _e) { + } + catch(Engines::DSC::BadPortType& _e) { + Py_BLOCK_THREADS PyErr_SetString(PyExc_ValueError,"Bad port type"); return NULL; - } catch(...) { + } + catch (SALOME_Exception &e) { + Py_BLOCK_THREADS + PyErr_SetString(PyExc_RuntimeError,e.what()); + return NULL; + } + catch (SALOME::SALOME_Exception &e) { + Py_BLOCK_THREADS + PyErr_SetString(PyExc_RuntimeError,e.details.text); + return NULL; + } + catch (const CORBA::SystemException& e) { + Py_BLOCK_THREADS + return api->handleCxxSystemException(e); + } + catch(...) { + Py_BLOCK_THREADS PyErr_SetString(PyExc_ValueError,"Unknown exception"); return NULL; } + Py_END_ALLOW_THREADS } /* @@ -522,6 +737,23 @@ class PySupervCompo:public Superv_Component_i virtual Ports::PortProperties_ptr get_port_properties(const char* port_name); +// Interface for Salome_file + Engines::Salome_file_ptr getInputFileToService(const char* service_name, const char* Salome_file_name); + void checkInputFilesToService(const char* service_name); + Engines::Salome_file_ptr setInputFileToService(const char* service_name, const char* Salome_file_name); + Engines::Salome_file_ptr getOutputFileToService(const char* service_name, const char* Salome_file_name); + void checkOutputFilesToService(const char* service_name); + Engines::Salome_file_ptr setOutputFileToService(const char* service_name, const char* Salome_file_name); +// End of Interface for Salome_file + +// DSC interface for python components + virtual void add_provides_port(Ports::Port_ptr ref, const char* provides_port_name, Ports::PortProperties_ptr port_prop); + virtual void add_uses_port(const char* repository_id, const char* uses_port_name, Ports::PortProperties_ptr port_prop); + virtual Engines::DSC::uses_port * get_uses_port(const char* uses_port_name); +// End of DSC interface for python components + + + %extend { //To get the address of the component @@ -541,25 +773,25 @@ class PySupervCompo:public Superv_Component_i extern "C" void create_calcium_port(Superv_Component_i* compo,char* name,char* type,char *mode,char* depend); -#define CP_TEMPS 40 -#define CP_ITERATION 41 -#define CP_SEQUENTIEL 42 -#define CP_CONT 20 -#define CP_ARRET 21 +%ignore CPMESSAGE; +%include "calciumP.h" + +int cp_cd(Superv_Component_i *component,char *name); -int cp_cd(void *component,char *name); +int cp_een(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,int *eval); +int cp_edb(Superv_Component_i *component,int dep,double t,int n,char *nom,int nval,double *eval); +int cp_ere(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *eval); +int cp_ecp(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *ecpval); +int cp_elo(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,int *eval); +int cp_ech(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,char** eval,int strSize); -int cp_een(void *component,int dep,float t,int n,char *nom,int nval,int *eval); -int cp_edb(void *component,int dep,double t,int n,char *nom,int nval,double *eval); -int cp_ere(void *component,int dep,float t,int n,char *nom,int nval,float *eval); -int cp_ecp(void *component,int dep,float t,int n,char *nom,int nval,float *eval); -int cp_elo(void *component,int dep,float t,int n,char *nom,int nval,int *eval); -int cp_len(void *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,int *lval); -int cp_ldb(void *component,int dep,double *ti,double *tf,int *niter,char *nom,int nmax,int *nval,double *lval); -int cp_lre(void *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lval); -int cp_lcp(void *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lval); -int cp_llo(void *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,int *lval); +int cp_len(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,int *lval); +int cp_ldb(Superv_Component_i *component,int dep,double *ti,double *tf,int *niter,char *nom,int nmax,int *nval,double *lval); +int cp_lre(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lval); +int cp_lcp(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lcpval); +int cp_llo(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,int *lval); +int cp_lch(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,char** lval,int strSize); -int cp_fin(void *component,int cp_end); +int cp_fin(Superv_Component_i *component,int cp_end); diff --git a/src/DSC/DSC_Python/dsccalcium.py b/src/DSC/DSC_Python/dsccalcium.py index c96fdc16c..48836d661 100644 --- a/src/DSC/DSC_Python/dsccalcium.py +++ b/src/DSC/DSC_Python/dsccalcium.py @@ -51,3 +51,21 @@ class PyDSCComponent(SALOME_ComponentPy.SALOME_ComponentPy_i, def get_port_properties(self,name): return self.proxy.get_port_properties(name) + def setInputFileToService(self,service_name,Salome_file_name): + return self.proxy.setInputFileToService(service_name,Salome_file_name) + + def checkInputFilesToService(self,service_name): + return self.proxy.checkInputFilesToService(service_name) + + def getInputFileToService(self,service_name,Salome_file_name): + return self.proxy.getInputFileToService(service_name,Salome_file_name) + + def setOutputFileToService(self,service_name,Salome_file_name): + return self.proxy.setOutputFileToService(service_name,Salome_file_name) + + def getOutputFileToService(self,service_name,Salome_file_name): + return self.proxy.getOutputFileToService(service_name,Salome_file_name) + + def checkOutputFilesToService(self,service_name): + return self.proxy.checkOutputFilesToService(service_name) + diff --git a/src/DSC/DSC_User/Basic/data_short_port_provides.hxx b/src/DSC/DSC_User/Basic/data_short_port_provides.hxx index df33f6551..51ae3afd9 100644 --- a/src/DSC/DSC_User/Basic/data_short_port_provides.hxx +++ b/src/DSC/DSC_User/Basic/data_short_port_provides.hxx @@ -26,6 +26,8 @@ #ifndef _DATA_SHORT_PORT_PROVIDES_HXX_ #define _DATA_SHORT_PORT_PROVIDES_HXX_ +#include + #include #include "SALOME_Ports.hh" #include "provides_port.hxx" diff --git a/src/DSC/DSC_User/Datastream/Calcium/Calcium.c b/src/DSC/DSC_User/Datastream/Calcium/Calcium.c index de497f752..cba14ca11 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Calcium.c +++ b/src/DSC/DSC_User/Datastream/Calcium/Calcium.c @@ -1,28 +1,28 @@ -// Copyright (C) 2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// -// File : Calcium.c -// Author : Eric Fayolle (EDF) -// Module : KERNEL -// Id : $Id$ +/* Copyright (C) 2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com */ + + + +/* File : Calcium.c */ +/* Author : Eric Fayolle (EDF) */ +/* Module : KERNEL */ +/* Id : $Id$ */ #include "calcium.h" #include @@ -32,14 +32,17 @@ // Interface C de SalomeCalcium typedef int InfoType; -typedef int bool; +typedef char bool; -// INTERFACES DE LECTURE +/* INTERFACES DE LECTURE en 0 copie */ +/* Definition des méthodes calcium étendues en 0 copie */ +/* Le buffer est alloué par le port pas par l'utilisateur */ +/* Remarquer le type ** de data */ +/* L'utilisateur devra appeler ecp_..._free pour désallouer le buffer interne */ +/* Attention en cas de lectures multiples : le buffer retourné est le même */ +/* Attention si les niveaux sont actifs le buffer peut être supprimé automatiquement par calcium. */ -// Definition des méthodes calcium étendues -// permettant le 0 copy. -//const char * nomvar #define CALCIUM_EXT_LECT_INTERFACE_C_(_name,_timeType,_type,_typeName,_qual) \ InfoType ecp_##_name (void * component, int mode, \ _timeType * ti, _timeType * tf, int * i, \ @@ -70,60 +73,116 @@ typedef int bool; ecp_lecture_##_typeName##_free(data); \ }; +#define STAR * CALCIUM_EXT_LECT_INTERFACE_C_(len,float,int,int,); CALCIUM_EXT_LECT_INTERFACE_C_(lre,float,float,float,); CALCIUM_EXT_LECT_INTERFACE_C_(ldb,double,double,double,); -CALCIUM_EXT_LECT_INTERFACE_C_(llo,float,bool,bool,); +/* CALCIUM_EXT_LECT_INTERFACE_C_(llo,float,bool,bool,); */ CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,); -#define STAR * -// CALCIUM_EXT_LECT_INTERFACE_C_(lch,float,char,STAR[]); -// La signature n'est pas la même pour les chaines de caractères il y a aussi -// la taille des chaines +/* CALCIUM_EXT_LECT_INTERFACE_C_(lch,float,char,STAR[]); */ -//const char * nomvar -#define CALCIUM_LECT_INTERFACE_C_(_name,_timeType,_type,_typeName,_qual) \ + +/* INTERFACES DE LECTURE avec recopie */ + +#define CALCIUM_LECT_INTERFACE_C_(_name,_timeType,_type,_typeName,_qual) \ InfoType cp_##_name (void * component, int mode, \ _timeType * ti, _timeType * tf, int * i, \ char * nomvar, int bufferLength, \ int * nRead, _type _qual * data ) { \ size_t _nRead; \ long _i=*i; \ - fflush(stdout); \ - fflush(stderr); \ - fprintf(stderr,"Beginning of CPLxx: %s %d %f\n",nomvar,*i,*ti); \ + fflush(stdout); \ + fflush(stderr); \ + fprintf(stderr,"Beginning of cp_" #_name " : %s %d %f\n",nomvar,*i,*ti); \ \ if ( (data == NULL) || (bufferLength < 1) ) return CPNTNULL; \ \ - InfoType info = ecp_lecture_##_typeName (component, mode, ti, tf, &_i, \ + InfoType info = ecp_lecture_##_typeName (component, mode, ti, tf, &_i, \ nomvar, bufferLength, &_nRead, \ - &data ); \ - if(mode == CP_SEQUENTIEL) \ - *i = _i; \ + &data ); \ + if(mode == CP_SEQUENTIEL) \ + *i = _i; \ *nRead=_nRead; \ - fprintf(stderr,"End of CPLxx: %s %d \n",nomvar,*i); \ - fflush(stdout); \ - fflush(stderr); \ + fprintf(stderr,"End of cp_" #_name " : %s %d \n",nomvar,*i); \ + fflush(stdout); \ + fflush(stderr); \ \ return info; \ }; \ void cp_##_name##_free ( _type _qual * data) { \ - ecp_lecture_##_typeName##_free(data); \ + ecp_lecture_##_typeName##_free(data); \ }; -// Definition des méthodes calcium standard + +InfoType cp_lch(void * component, int mode, float * ti, float * tf, int * i, + char * nomvar, int bufferLength, int * nRead, + char ** data, int strSize) { + + size_t _nRead; + long _i=*i; + fflush(stdout);fflush(stderr); + fprintf(stderr,"Beginning of cp_lch: %s %d %f\n",nomvar,*i,*ti); + + if ( (data == NULL) || (bufferLength < 1) ) return CPNTNULL; + + InfoType info = ecp_lecture_str (component, mode, ti, tf, &_i, + nomvar, bufferLength, &_nRead, + &data);/*, strSize );*/ + if(mode == CP_SEQUENTIEL) + *i = _i; + *nRead=_nRead; + fprintf(stderr,"End of cp_lch: %s %d \n",nomvar,*i); + fflush(stdout);fflush(stderr); + + return info; +}; + +InfoType cp_llo(void * component, int mode, float * ti, float * tf, int * i, + char * nomvar, int bufferLength, int * nRead, + int * data ) { + + bool *dLogique=NULL; + size_t _nRead; + long _i=*i; + int j; + fflush(stdout);fflush(stderr); + fprintf(stderr,"Beginning of cpllo: %s %d %f\n",nomvar,*i,*ti); + + if ( (data == NULL) || (bufferLength < 1) ) return CPNTNULL; + + dLogique = (bool *) malloc(bufferLength * sizeof(int)); + + InfoType info = ecp_lecture_bool (component, mode, ti, tf, &_i, + nomvar, bufferLength, &_nRead, + &dLogique); + if(mode == CP_SEQUENTIEL) + *i = _i; + *nRead=_nRead; + + for ( j=0; j<_nRead; ++j) data[j] = dLogique[j]; + free(dLogique); + + fprintf(stderr,"End of cpllo: %s %d \n",nomvar,*i); + fflush(stdout);fflush(stderr); + + return info; +}; + + +/* Definition des méthodes calcium standard */ CALCIUM_LECT_INTERFACE_C_(len,float,int,int,); CALCIUM_LECT_INTERFACE_C_(lre,float,float,float,); CALCIUM_LECT_INTERFACE_C_(ldb,double,double,double,); -CALCIUM_LECT_INTERFACE_C_(llo,float,bool,bool,); +/* CALCIUM_LECT_INTERFACE_C_(llo,float,bool,bool,); */ CALCIUM_LECT_INTERFACE_C_(lcp,float,float,cplx,); #define STAR * -// CALCIUM_LECT_INTERFACE_C_(lch,float,char,STAR); +/* CALCIUM_LECT_INTERFACE_C_(lch,float,char,STAR); */ -// INTERFACES DE DÉBUT ET DE FIN DE COUPLAGE +/* INTERFACES DE DÉBUT ET DE FIN DE COUPLAGE */ InfoType cp_cd (void * component, char * instanceName) { /* TODO : Trouver le nom de l'instance SALOME*/ @@ -139,6 +198,7 @@ InfoType cp_fin (void * component, int code) { } +/* INTERFACES D'ECRITURE */ #define CALCIUM_ECR_INTERFACE_C_(_name,_timeType,_type,_typeName,_qual) \ InfoType cp_##_name (void * component, int mode, \ @@ -147,27 +207,74 @@ InfoType cp_fin (void * component, int code) { _type _qual * data ) { \ \ /*long _i=i;*/ \ - fflush(stdout); \ - fflush(stderr); \ - fprintf(stderr,"Beginning of CPExx: %s %d %f\n",nomvar,i,t); \ + fflush(stdout); \ + fflush(stderr); \ + fprintf(stderr,"Beginning of cp_" #_name " : %s %d %f\n",nomvar,i,t); \ if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL; \ \ InfoType info = ecp_ecriture_##_typeName (component, mode, &t, i, \ nomvar, nbelem, \ data ); \ - fprintf(stderr,"End of CPExx: %s %d \n",nomvar,i); \ - fflush(stdout); \ - fflush(stderr); \ + fprintf(stderr,"End of cp_" #_name " : %s %d \n",nomvar,i); \ + fflush(stdout); \ + fflush(stderr); \ \ return info; \ }; \ -// Definition des méthodes calcium standard + +InfoType cp_ech(void * component, int mode, float t, int i, + char * nomvar, int nbelem, + char ** data, int strSize) { + + /*long _i=i;*/ + fflush(stdout);fflush(stderr); + fprintf(stderr,"Beginning of cp_ech: %s %d %f\n",nomvar,i,t); + if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL; + + InfoType info = ecp_ecriture_str (component, mode, &t, i, + nomvar, nbelem, + data);/*, strSize );*/ + fprintf(stderr,"End of cp_ech: %s %d \n",nomvar,i); + fflush(stdout); + fflush(stderr); + + return info; +}; + +InfoType cp_elo(void * component, int mode, float t, int i, + char * nomvar, int nbelem, + int * data ) { + + /*long _i=i;*/ + bool * dLogique = NULL; + int j=0; + fflush(stdout);fflush(stderr); + fprintf(stderr,"Beginning of cpelo: %s %d %f\n",nomvar,i,t); + if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL; + + dLogique = (bool *) malloc(nbelem * sizeof(int)); + for (j=0; j(port)->setDependencyType(depend); } + else if(std::string(type)=="CALCIUM_string") + { + dynamic_cast(port)->setDependencyType(depend); + } + else if(std::string(type)=="CALCIUM_logical") + { + dynamic_cast(port)->setDependencyType(depend); + } + else if(std::string(type)=="CALCIUM_complex") + { + dynamic_cast(port)->setDependencyType(depend); + } else { std::cerr << "unknown type:" << std::endl; diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.hxx index a6c301ee6..1fe1c0e5b 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.hxx @@ -34,6 +34,8 @@ #include "CouplingPolicy.hxx" #include "AdjacentFunctor.hxx" #include +#include +#include #include "CalciumTypes.hxx" #include "CalciumException.hxx" @@ -44,7 +46,8 @@ public: template class InternalDataIdContainer; template friend class InternalDataIdContainer; - template friend class BoundedDataIdProcessor; + template friend class BoundedDataIdProcessor; template friend class EraseDataIdProcessor; template friend class DisconnectProcessor; @@ -103,8 +106,9 @@ public: inline TimeType getTime(const DataId &dataId) const { return dataId.first;} inline TagType getTag (const DataId &dataId) const { return dataId.second;} - // TODO : Vérifier l'application pour tous les types de données - template struct BoundedDataIdProcessor; + template struct BoundedDataIdProcessor; + //template struct BoundedDataIdProcessor; template struct EraseDataIdProcessor; template struct DisconnectProcessor; @@ -157,10 +161,24 @@ struct CalciumCouplingPolicy::InternalDataIdContainer : public std::vector< std: }; -// TODO : Vérifier l'application pour tous les types de données -// DESACTIVER POUR ?BOOL? et CHAR * -template +template struct CalciumCouplingPolicy::BoundedDataIdProcessor{ + BoundedDataIdProcessor(const CouplingPolicy & couplingPolicy) {}; + template < typename Iterator, typename DataId > + void inline apply(typename iterator_t::value_type & data, + const DataId & dataId, + const Iterator & it1) const { + typedef typename iterator_t::value_type value_type; + std::cout << "-------- Calcium Generic BoundedDataIdProcessor.apply() called " << std::endl; + + } +}; + + +template +struct CalciumCouplingPolicy::BoundedDataIdProcessor< + DataManipulator, + typename boost::enable_if< boost::is_float< typename DataManipulator::InnerType> >::type > { const CalciumCouplingPolicy & _couplingPolicy; @@ -232,8 +250,8 @@ struct CalciumCouplingPolicy::BoundedDataIdProcessor{ boost::lambda::placeholder1_type _1; boost::lambda::placeholder2_type _2; - // REM : Pour des buffers de type int - // le compilo indiquera warning: converting to `long int' from `Double' + // OLD: REM : Pour des buffers de type int + // OLD: le compilo indiquera warning: converting to `long int' from `Double' std::transform(InIt1,InIt1+dataSize,InIt2,OutIt, ( _1 - _2 ) * coeff + _2 ); // for(size_t i =0; i < dataSize3; ++i) { diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx index 71f157f16..504d3b256 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx @@ -29,461 +29,22 @@ #ifndef _CALCIUM_INTERFACE_HXX_ #define _CALCIUM_INTERFACE_HXX_ -#include -#include -#include -#include "Superv_Component_i.hxx" +//Interface C++ +#include "CalciumCxxInterface.hxx" + #include "CalciumException.hxx" #include "CalciumTypes.hxx" -#include "CalciumGenericUsesPort.hxx" -#include "Copy2UserSpace.hxx" -#include "Copy2CorbaSpace.hxx" -#include "CalciumPortTraits.hxx" #include //#define _DEBUG_ -// Déplacer cette information dans CorbaTypeManipulator -// Gérer en même temps la recopie profonde. - -template -struct IsSameType { - static const bool value = false; -}; -template -struct IsSameType { - static const bool value = true; -}; - - - - -//class CalciumInterface { -namespace CalciumInterface { -//public : - - - static void - ecp_fin (Superv_Component_i & component, bool provideLastGivenValue) - { - std::vector usesPortNames; - std::vector::const_iterator it; - component.get_uses_port_names(usesPortNames); - - //récupérer le type de réel du port est un peu difficile - //car l'interface nous donne aucune indication - - // uses_port *myUsesPort; - calcium_uses_port* myCalciumUsesPort; - - for (it=usesPortNames.begin(); it != usesPortNames.end(); ++it) { - try { - - myCalciumUsesPort= - component.Superv_Component_i::get_port< calcium_uses_port >((*it).c_str()); - -// component.Superv_Component_i::get_port(myUsesPort,(*it).c_str()); -// calcium_uses_port* myCalciumUsesPort= -// dynamic_cast(myUsesPort); - -#ifdef _DEBUG_ - std::cerr << "-------- CalciumInterface(ecp_fin) MARK 1 -|"<< *it <<"|----"<< - // typeid(myUsesPort).name() <<"-------------" << - typeid(myCalciumUsesPort).name() <<"-------------" << std::endl; -#endif - -// if ( !myCalciumUsesPort ) -// throw Superv_Component_i::BadCast(LOC(OSS()<<"Impossible de convertir le port " -// << *it << " en port de type calcium_uses_port." )); - - myCalciumUsesPort->disconnect(provideLastGivenValue); - - } catch ( const Superv_Component_i::BadCast & ex) { -#ifdef _DEBUG_ - std::cerr << ex.what() << std::endl; -#endif - throw (CalciumException(CalciumTypes::CPTPVR,ex)); - } catch ( const DSC_Exception & ex) { -#ifdef _DEBUG_ - std::cerr << ex.what() << std::endl; -#endif - // Exception venant de SupervComponent : - // PortNotDefined(CPNMVR), PortNotConnected(CPLIEN) - // ou du port uses : Dsc_Exception - // On continue à traiter la deconnexion des autres ports uses - } catch (...) { - throw (CalciumException(CalciumTypes::CPATAL,"Exception innatendue")); - // En fonction du mode de gestion des erreurs throw; - } - } - } - - - // Uniquement appelé par l'utilisateur s'il a passé un pointeur de données NULL - // à l'appel de ecp_lecture (demande de 0 copie) - template static void - ecp_free ( T1 * dataPtr ) - { - typedef typename ProvidesPortTraits::PortType PortType; - typedef typename PortType::DataManipulator DataManipulator; - typedef typename DataManipulator::Type DataType; // Attention != T - typedef typename DataManipulator::InnerType InnerType; - - DeleteTraits::value >::apply(dataPtr); - } - - template static void - ecp_free ( T1 * dataPtr ) - { - ecp_free ( dataPtr ); - } - - template static void - ecp_lecture ( Superv_Component_i & component, - CalciumTypes::DependencyType dependencyType, - double & ti, - double const & tf, - long & i, - const string & nomVar, - size_t bufferLength, - size_t & nRead, - T1 * &data ) - { - ecp_lecture (component,dependencyType,ti,tf, - i,nomVar,bufferLength,nRead,data); - - } - - template static void - ecp_lecture ( Superv_Component_i & component, - CalciumTypes::DependencyType dependencyType, - double & ti, - double const & tf, - long & i, - const string & nomVar, - size_t bufferLength, - size_t & nRead, - T1 * &data ) - { - - assert(&component); - - typedef typename ProvidesPortTraits::PortType PortType; - typedef typename PortType::DataManipulator DataManipulator; - typedef typename DataManipulator::Type CorbaDataType; // Attention != T - typedef typename DataManipulator::InnerType InnerType; - - CorbaDataType corbaData; - long ilong; - #ifdef _DEBUG_ - std::cerr << "-------- CalciumInterface(ecp_lecture) MARK 1 ------------------" << std::endl; -#endif - - if (nomVar.empty()) - throw CalciumException(CalciumTypes::CPNMVR, - LOC("Le nom de la variable est ")); - PortType * port; -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 2 ------------------" << std::endl; -#endif - - try { - port = component.Superv_Component_i::get_port< PortType > (nomVar.c_str()); -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 3 ------------------" << std::endl; -#endif - } catch ( const Superv_Component_i::PortNotDefined & ex) { -#ifdef _DEBUG_ - std::cerr << ex.what() << std::endl; -#endif - throw (CalciumException(CalciumTypes::CPNMVR,ex)); - } catch ( const Superv_Component_i::PortNotConnected & ex) { -#ifdef _DEBUG_ - std::cerr << ex.what() << std::endl;; -#endif - throw (CalciumException(CalciumTypes::CPLIEN,ex)); - // VERIFIER LES CAS DES CODES : CPINARRET, CPSTOPSEQ, CPCTVR, CPLIEN - } catch ( const Superv_Component_i::BadCast & ex) { -#ifdef _DEBUG_ - std::cerr << ex.what() << std::endl; -#endif - throw (CalciumException(CalciumTypes::CPTPVR,ex)); - } - - // mode == mode du port - CalciumTypes::DependencyType portDependencyType = port->getDependencyType(); - - if ( portDependencyType == CalciumTypes::UNDEFINED_DEPENDENCY ) - throw CalciumException(CalciumTypes::CPIT, - LOC(OSS()<<"Le mode de dépendance de la variable " - << nomVar << " est indéfini.")); - - if ( ( portDependencyType != dependencyType ) && - ( dependencyType != CalciumTypes::SEQUENCE_DEPENDENCY ) ) - throw CalciumException(CalciumTypes::CPITVR, - LOC(OSS()<<"Le mode de dépendance de la variable " - << nomVar << " ne correspond pas au mode demandé.")); - - - if ( dependencyType == CalciumTypes::TIME_DEPENDENCY ) { - corbaData = port->get(ti,tf, 0); -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 5 ------------------" << std::endl; -#endif - } - else if ( dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) { - corbaData = port->get(0, i); -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 6 ------------------" << std::endl; -#endif - } else { - // Lecture en séquence -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 7 ------------------" << std::endl; -#endif - corbaData = port->next(ti,i); - } - -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 8 ------------------" << std::endl; -#endif - size_t corbaDataSize = DataManipulator::size(corbaData); -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) corbaDataSize : " << corbaDataSize << std::endl; -#endif - - // Vérifie si l'utilisateur demande du 0 copie - if ( data == NULL ) { - if ( bufferLength != 0 ) { - MESSAGE("bufferLength devrait valoir 0 pour l'utilisation du mode sans copie (data==NULL)"); - } - nRead = corbaDataSize; - // Si les types T et InnerType sont différents, il faudra effectuer tout de même une recopie - if (!IsSameType::value) data = new T1[nRead]; -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 9 ------------------" << std::endl; -#endif - // On essaye de faire du 0 copy si les types T et InnerType sont les mêmes - Copy2UserSpace< IsSameType::value >::apply(data,corbaData,nRead); -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 10 ------------------" << std::endl; -#endif - // Attention : Seul CalciumCouplingPolicy via eraseDataId doit décider de supprimer ou non - // la donnée corba associée à un DataId ! Ne pas effectuer la desallocation suivante : - // old : Dans les deux cas la structure CORBA n'est plus utile - // old : Si !IsSameType::value l'objet CORBA est détruit avec son contenu - // old : Dans l'autre cas seul la coquille CORBA est détruite - // tjrs correct : Dans les deux cas l'utilisateur devra appeler ecp_free (version modifiée) - // DataManipulator::delete_data(corbaData); - } else { - nRead = std::min < size_t > (corbaDataSize,bufferLength); -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 11 ------------------" << std::endl; -#endif - Copy2UserSpace::apply(data,corbaData,nRead); -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 12 ------------------" << std::endl; -#endif - // Attention : Seul CalciumCouplingPolicy via eraseDataId doit décider de supprimer ou non - // la donnée corba associée à un DataId ! Ne pas effectuer la desallocation suivante : - // DataManipulator::delete_data(corbaData); - } -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecp_lecture), Valeur de data : " << std::endl; - std::copy(data,data+nRead,std::ostream_iterator(std::cout," ")); - std::cout << "Ptr :" << data << std::endl; - - std::cout << "-------- CalciumInterface(ecp_lecture) MARK 13 ------------------" << std::endl; -#endif - - - return; - } - - - template static void - ecp_ecriture ( Superv_Component_i & component, - CalciumTypes::DependencyType dependencyType, - double const & t, - long const & i, - const string & nomVar, - size_t bufferLength, - T1 & data ) { - ecp_ecriture (component,dependencyType,t,i,nomVar,bufferLength,data); - } - - template static void - ecp_ecriture ( Superv_Component_i & component, - CalciumTypes::DependencyType dependencyType, - double const & t, - long const & i, - const string & nomVar, - size_t bufferLength, - T1 & data ) - { - - assert(&component); - - //typedef typename StarTrait::NonStarType T; - typedef typename UsesPortTraits::PortType PortType; - typedef typename ProvidesPortTraits::PortType ProvidesPortType; - typedef typename ProvidesPortType::DataManipulator DataManipulator; - // Verifier que l'on peut définir UsesPortType::DataManipulator - // typedef typename PortType::DataManipulator DataManipulator; - typedef typename DataManipulator::Type CorbaDataType; // Attention != T1 - typedef typename DataManipulator::InnerType InnerType; - -#ifdef _DEBUG_ - std::cerr << "-------- CalciumInterface(ecriture) MARK 1 ------------------" << std::endl; -#endif - if ( nomVar.empty() ) throw CalciumException(CalciumTypes::CPNMVR, - LOC("Le nom de la variable est ")); - PortType * port; -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecriture) MARK 2 ------------------" << std::endl; -#endif - - try { - port = component.Superv_Component_i::get_port< PortType > (nomVar.c_str()); -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecriture) MARK 3 ------------------" << std::endl; -#endif - } catch ( const Superv_Component_i::PortNotDefined & ex) { -#ifdef _DEBUG_ - std::cerr << ex.what() << std::endl; -#endif - throw (CalciumException(CalciumTypes::CPNMVR,ex)); - } catch ( const Superv_Component_i::PortNotConnected & ex) { -#ifdef _DEBUG_ - std::cerr << ex.what() << std::endl;; -#endif - throw (CalciumException(CalciumTypes::CPLIEN,ex)); - // VERIFIER LES CAS DES CODES : CPINARRET, CPSTOPSEQ, CPCTVR, CPLIEN - } catch ( const Superv_Component_i::BadCast & ex) { -#ifdef _DEBUG_ - std::cerr << ex.what() << std::endl; -#endif - throw (CalciumException(CalciumTypes::CPTPVR,ex)); - } - - // mode == mode du port - // On pourrait créer la méthode CORBA dans le mode de Couplage CALCIUM. - // et donc ajouter cette cette méthode uniquement dans l'IDL calcium ! - -// CalciumTypes::DependencyType portDependencyType; -// try { -// portDependencyType = port->getDependencyType(); -// std::cout << "-------- CalciumInterface(ecriture) MARK 4 ------------------" << std::endl; -// } catch ( const DSC_Exception & ex ) { -// std::cerr << ex.what() << std::endl;; -// throw (CalciumException(CalciumTypes::CPIT,ex)); -// } - - if ( dependencyType == CalciumTypes::UNDEFINED_DEPENDENCY ) - throw CalciumException(CalciumTypes::CPIT, - LOC(OSS()<<"Le mode de dépendance demandé pour la variable " - << nomVar << " est indéfini.")); - - if ( dependencyType == CalciumTypes::SEQUENCE_DEPENDENCY ) - throw CalciumException(CalciumTypes::CPIT, - LOC(OSS()<<"Le mode de dépendance SEQUENCE_DEPENDENCY pour la variable " - << nomVar << " est impossible en écriture.")); - - // Il faudrait que le port provides génère une exception si le mode donnée n'est pas - // le bon. La seule façon de le faire est d'envoyer -1 en temps si on n'est en itération - // et vice-versa pour informer les provides port du mode dans lequel on est. Sinon il faut - // modifier l'interface IDL pour y ajouter un mode de dépendance ! - // ----> -// if ( portDependencyType != dependencyType ) -// throw CalciumException(CalciumTypes::CPITVR, -// LOC(OSS()<<"Le mode de dépendance de la variable " -// << nomVar << " ne correspond pas au mode demandé.")); - - - if ( bufferLength < 1 ) - throw CalciumException(CalciumTypes::CPNTNULL, - LOC(OSS()<<"Le buffer a envoyer est de taille nulle ")); - - -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecriture) MARK 4 ------------------" << std::endl; -#endif - CorbaDataType corbaData; - - - // Si les types Utilisateurs et CORBA sont différents - // il faut effectuer une recopie sinon on utilise directement le - // buffer data pour constituer la séquence - // TODO : - // - Attention en mode asynchrone il faudra eventuellement - // faire une copie des données même si elles sont de même type. - // - En cas de collocalisation (du port provide et du port uses) - // il est necessaire d'effectuer une recopie du buffer car la - // séquence est envoyée au port provide par une référence sur - // la séquence locale. Or la méthode put récupère le buffer directement - // qui est alors le buffer utilisateur. Il pourrait alors arrivé que : - // * Le recepteur efface le buffer emetteur - // * Le port lui-même efface le buffer de l'ulisateur ! - // Cette copie est effectuée dans GenericPortUses::put - // en fonction de la collocalisation ou non. - // - En cas de connection multiples d'un port uses distant vers plusieurs port provides - // collocalisés les ports provides partagent la même copie de la donnée ! - // Il faut effectuer une copie dans le port provides. - // Cette copie est effectuée dans GenericPortUses::put - // en fonction de la collocalisation ou non. - Copy2CorbaSpace::value >::apply(corbaData,data,bufferLength); - - //TODO : GERER LES EXCEPTIONS ICI : ex le port n'est pas connecté - if ( dependencyType == CalciumTypes::TIME_DEPENDENCY ) { - try - { - port->put(*corbaData,t, -1); - } - catch ( const DSC_Exception & ex) - { - throw (CalciumException(CalciumTypes::CPATAL,ex.what())); - } - //Le -1 peut être traité par le cst DataIdContainer et transformé en 0 - //Etre obligé de mettre une étoile ds (*corbadata) va poser des pb pour les types <> seq -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecriture) MARK 5 ------------------" << std::endl; -#endif - } - else if ( dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) { - try - { - port->put(*corbaData,-1, i); - } - catch ( const DSC_Exception & ex) - { - throw (CalciumException(CalciumTypes::CPATAL,ex.what())); - } -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecriture) MARK 6 ------------------" << std::endl; -#endif - } - - -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecriture), Valeur de corbaData : " << std::endl; - for (int i = 0; i < corbaData->length(); ++i) - cout << "-------- CalciumInterface(ecriture), corbaData[" << i << "] = " << (*corbaData)[i] << endl; +#define DEBTRACE(msg) {std::cerr<::value ) delete corbaData; - // Supprime l'objet CORBA avec eventuellement les données qu'il contient (case de la recopie) - delete corbaData; -#ifdef _DEBUG_ - std::cout << "-------- CalciumInterface(ecriture) MARK 7 ------------------" << std::endl; -#endif - - return; - } - -}; // Interface C/C++ @@ -498,6 +59,7 @@ template <> struct CalTimeType { typedef double TimeType; }; +// Définition de ecp_fin extern "C" CalciumTypes::InfoType ecp_fin_ (void * component, int code) { @@ -510,21 +72,14 @@ ecp_fin_ (void * component, int code) { CalciumInterface::ecp_fin( *_component, provideLastGivenValue); } catch ( const CalciumException & ex) { //tester l'arrêt par exception -#ifdef _DEBUG_ - std::cerr << ex.what() << std::endl; -#endif + DEBTRACE( ex.what() ); return ex.getInfo(); } return CalciumTypes::CPOK; }; -#ifdef _DEBUG_ -#define DEBTRACE(msg) {std::cerr<::TimeType * ti, \ @@ -548,9 +103,7 @@ ecp_fin_ (void * component, int code) { nomvar, \ _bufferLength, _nRead, *data); \ } catch ( const CalciumException & ex) { \ - DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1b ------------------" ) \ - DEBTRACE( ex.what() ) \ - DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1ter ------------------" ) \ + DEBTRACE( ex.what() ); \ return ex.getInfo(); \ } \ if ( IsSameType< _name , cplx >::value ) { *nRead=_nRead/2; \ @@ -561,16 +114,15 @@ ecp_fin_ (void * component, int code) { if (_dependencyType == CalciumTypes::CP_SEQUENTIEL ) \ *ti=(CalTimeType< _type _qual >::TimeType)(_ti); \ DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data ) \ - /* \ - for (int i=0; i<_nRead;++i) \ - printf("-------- CalciumInterface(lecture Inter Part), Valeur de data (typage entier) data[%d] : %d \n",i,(*data)[i]); \ - */ \ - DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data ) \ return CalciumTypes::CPOK; \ }; \ + \ + \ extern "C" void ecp_lecture_##_name##_free ( _type _qual * data) { \ CalciumInterface::ecp_free< _type, _name >(data); \ }; \ + \ + \ extern "C" CalciumTypes::InfoType ecp_ecriture_##_name (void * component, int dependencyType, \ CalTimeType< _type _qual >::TimeType *t, \ long i, \ @@ -593,23 +145,102 @@ ecp_fin_ (void * component, int code) { std::cerr << ex.what() << std::endl; \ return ex.getInfo(); \ } \ - DEBTRACE( "-------- CalciumInterface(ecriture Inter Part), Valeur de data : " ) \ - DEBTRACE( "-------- CalciumInterface(ecriture Inter Part), Ptr(1) :" << data ) \ - /* \ - for (int i=0; i<_bufferLength;++i) \ - printf("-------- CalciumInterface(ecriture Inter Part), Valeur de data (typage entier) data[%d] : %d \n",i,data[i]); \ - */ \ - DEBTRACE( "-------- CalciumInterface(ecriture Inter Part), Ptr(2) :" << data ) \ - return CalciumTypes::CPOK; \ + DEBTRACE( "-------- CalciumInterface(ecriture Inter Part), Valeur de data :" << data ) \ + return CalciumTypes::CPOK; \ }; \ #define STAR * +// Le premier argument est utilisée : +// - comme suffixe dans la définition des noms ecp_lecture_ ecp_ecriture_ ecp_free_ +// - comme second argument template à l'appel de la méthode C++ correspondante +// ( le port correspondant est alors obtenu par un trait) +// Le second argument est utilisée : +// - pour typer le paramètre data de la procédure générée +// - pour déduire le type des paramètres t, ti tf via un trait +// - comme premier paramètre template à l'appel de la méthode C++ correspondante CALCIUM_C2CPP_INTERFACE_(int,int,); CALCIUM_C2CPP_INTERFACE_(float,float, ); CALCIUM_C2CPP_INTERFACE_(double,double,); CALCIUM_C2CPP_INTERFACE_(bool,bool,); CALCIUM_C2CPP_INTERFACE_(cplx,float,); +CALCIUM_C2CPP_INTERFACE_(str,char*,); + +// INTERFACE C/CPP pour les chaines de caractères +// Le paramètre supplémentaire strsize n'étant pas utilisé +// j'utilise la génération par la macro CALCIUM_C2CPP_INTERFACE_(str,char*,); +// TODO : vérifier ecp_free pour ce type particulier +// extern "C" CalciumTypes::InfoType ecp_lecture_str (void * component, int dependencyType, +// float * ti, float * tf, long * i, +// const char * const nomvar, size_t bufferLength, +// size_t * nRead, char ** *data, size_t strsize ) { + +// Superv_Component_i * _component = static_cast(component); +// double _ti=*ti; +// double _tf=*tf; +// size_t _nRead=0; +// size_t _bufferLength=bufferLength; +// CalciumTypes::DependencyType _dependencyType= +// static_cast(dependencyType); + +// // - GERER POINTEUR NULL : NOTHING TODO +// // - VERIFIER LA TAILLE DES CHAINES RETOURNEES (ELLES DEVRAIENT ETRES CORRECTES SI L'ECRITURE EST BIEN CODEE.) + +// DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" ) +// try { +// CalciumInterface::ecp_lecture< char*, char* >( *_component, +// _dependencyType, +// _ti, _tf, *i, +// nomvar, +// _bufferLength, _nRead, *data); +// } catch ( const CalciumException & ex) { +// DEBTRACE( ex.what() ); +// return ex.getInfo(); +// } + +// *nRead = _nRead; + +// if (_dependencyType == CalciumTypes::CP_SEQUENTIEL ) +// *ti=(float)(_ti); + +// DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data ) ; + +// return CalciumTypes::CPOK; +// }; + + +// extern "C" void ecp_lecture_str_free (char** data) { +// CalciumInterface::ecp_free< char*, char* >(data); +// }; + + +// extern "C" CalciumTypes::InfoType ecp_ecriture_str (void * component, int dependencyType, +// float *t, long i, +// const char * const nomvar, size_t bufferLength, +// char ** data, int strsize ) { + +// Superv_Component_i * _component = static_cast(component); +// /* Je ne sais pas pourquoi, je n'arrive pas à passer t par valeur : corruption de la pile*/ +// double _t=*t; +// size_t _bufferLength=bufferLength; + +// // - VERIFIER LA TAILLE DES CHAINES RETOURNEES (ELLES DEVRAIENT ETRES CORRECTES SI L'ECRITURE EST BIEN CODEE.) + +// DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 1 ------------------" ) +// try { +// std::string essai(nomvar); +// DEBTRACE( "----------->-" << nomvar ) +// CalciumInterface::ecp_ecriture< char*, char* >( *_component, +// static_cast(dependencyType), +// _t,i,nomvar,_bufferLength,*data); +// } catch ( const CalciumException & ex) { +// std::cerr << ex.what() << std::endl; +// return ex.getInfo(); +// } +// DEBTRACE( "-------- CalciumInterface(ecriture Inter Part), Valeur de data :" << data ) +// return CalciumTypes::CPOK; +// }; + #endif diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumPortTraits.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumPortTraits.hxx index baacd9c77..d05cc440d 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumPortTraits.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumPortTraits.hxx @@ -31,10 +31,10 @@ #include "Superv_Component_i.hxx" - -struct UnknownPortType {}; +// PROVIDES PORT TRAITS +struct UnknownProvidesPortType {}; template struct ProvidesPortTraits { - typedef UnknownPortType PortType; + typedef UnknownProvidesPortType PortType; }; template <> struct ProvidesPortTraits { typedef calcium_integer_port_provides PortType; @@ -48,25 +48,33 @@ template <> struct ProvidesPortTraits { template <> struct ProvidesPortTraits { typedef calcium_double_port_provides PortType; }; -template <> struct ProvidesPortTraits { - typedef calcium_string_port_provides PortType; -}; template <> struct ProvidesPortTraits { typedef calcium_logical_port_provides PortType; }; - // Définition du type cplx pour disciminer ce type de port // de celui du float struct cplx {}; template <> struct ProvidesPortTraits { typedef calcium_complex_port_provides PortType; }; +// Défénition du type str pour obtenir le type de port +// correspondant +struct str {}; +template <> struct ProvidesPortTraits { + typedef calcium_string_port_provides PortType; +}; + template <> struct ProvidesPortTraits { + typedef calcium_string_port_provides PortType; + }; template < typename T > struct StarTrait { typedef T NonStarType; }; template < typename T > struct StarTrait< T * > { typedef T NonStarType; }; + +// USES PORT TRAITS +struct UnknownUsesPortType {}; template struct UsesPortTraits { - typedef UnknownPortType PortType; + typedef UnknownUsesPortType PortType; }; template <> struct UsesPortTraits { typedef calcium_integer_port_uses PortType; @@ -80,7 +88,7 @@ template <> struct UsesPortTraits { template <> struct UsesPortTraits { typedef calcium_double_port_uses PortType; }; -template <> struct UsesPortTraits { +template <> struct UsesPortTraits { typedef calcium_string_port_uses PortType; }; template <> struct UsesPortTraits { diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumProvidesPort.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumProvidesPort.hxx index 075132663..e22288f6a 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumProvidesPort.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumProvidesPort.hxx @@ -6,6 +6,8 @@ #ifndef _CALCIUM_PORT_PROVIDES_HXX_ #define _CALCIUM_PORT_PROVIDES_HXX_ +#include + #include "Calcium_Ports.hh" #include "CalciumGenericProvidesPort.hxx" #include "CalciumCouplingPolicy.hxx" diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumTypes2CorbaTypes.cxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumTypes2CorbaTypes.cxx index 5cf6d10c5..5f7dcc18b 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumTypes2CorbaTypes.cxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumTypes2CorbaTypes.cxx @@ -49,11 +49,11 @@ table[CalciumTypes::UNDEFINED_DEPENDENCY ] = Ports::Calcium_Ports::UNDEFINED_DEP #ifdef _DEBUG_ -std::cout << "CORBA_DEPENDENCY_TYPE() : table["<& ) *this ; #ifdef _DEBUG_ -std::cout << "CORBA_DEPENDENCY_TYPE() : ::operator["< { std::cerr << "-------- Copy2CorbaSpace MARK 1 --(dataPtr : " << dataPtr<<")----------------" << std::endl; #endif - + // Attention : Pour les chaines ou tout autre object complexe il faut utiliser une recopie profonde ! std::copy(&data,&data+nRead,dataPtr); #ifdef _DEBUG_ diff --git a/src/DSC/DSC_User/Datastream/Calcium/Copy2UserSpace.hxx b/src/DSC/DSC_User/Datastream/Calcium/Copy2UserSpace.hxx index 36d18e37d..be959838e 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Copy2UserSpace.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/Copy2UserSpace.hxx @@ -33,6 +33,11 @@ #include #include "CalciumPortTraits.hxx" +#include + +//Les demandes de copies vers l'espace utilisateur +//proviennent d'une procédure de lecture + //Cas du zero copie template struct Copy2UserSpace{ @@ -40,66 +45,108 @@ struct Copy2UserSpace{ template static void apply( T1 * & data, T2 & corbaData, size_t nRead ){ + // La ligne suivante appelle à un commentaire + // dans le cas de char *, cf CalciumPortTraits.hxx 'char *' vs 'str' typedef typename ProvidesPortTraits::PortType PortType; typedef typename PortType::DataManipulator DataManipulator; typedef typename DataManipulator::InnerType InnerType; // Devient propriétaire des données contenues dans la structure CORBA // (allouées par allocbuff() pour une séquence) + // Le client est propriétaire des données. + // Il doit cependant être attentif au fait que s'il les modifie, + // une nouvelle demande de lecture lui fournira les données modifiées. + // TODO : ? Si plusieurs lecteurs demandent la même donnée ? + // ? qui devient le propriétaire? --> normalement le premier car + // ensuite la séquence n'est plus propriétaire. + // NO: Le port devrait resté propriétaire du contenu de la séquence + // NO: L'utilisateur doit de toute les façons utiliser les données reçues en + // NO: lecture seulement car si une nouvelle demande de lecture est formulée + // NO: pour ces données, les eventuelles modifications seraient visibles ! + // YES : La solution de donner la propriété à l'utilisateur est convenable car si + // le port déréférence ces données (garbage collecteur, niveau) le buffer + // reste disponible à l'ulisateur en lecture et écriture + // Le problème est que la donnée CORBA stockée par le port est maintenant vide (cf CORBA BOOK) + // du coup quid d'une nouvelle demande de lecture : A TESTER InnerType * dataPtr = DataManipulator::getPointer(corbaData,true); // Cette ligne poserait uun problème dans la méthode appelante, si elle // ne testait pas que les types utilisateurs et CORBA sont identiques : // ex : InnerType == Corba::Long et d'un T == int + // C'est l'objet de la procédure suivante data = dataPtr; - // L'utilisateur a la charge de la desallocation - // il devra appeler la méthode ecp_free pour désallouer le contenu de la séquence CORBA - // La structure CORBA sera désallouer le cas échéant dans la méthode appelante + // En zero copie l'utilisateur doit appeler ecp_free ( cas ou un buffer intermédiaire + // a été alloué pour cause de typage différent xor necessité de désalouer le buffer alloué par CORBA) + // L'utilisateur doit cependant être attentif au fait qu'après désallocation, si la donnée + // est toujours estampillée dans le port une nouvelle lecture pour cette estampille + // rendrait un buffer vide. } }; // Cas où il faut effectuer une recopie template <> -struct Copy2UserSpace{ +struct Copy2UserSpace { - //Recopie le contenu de la donnée CORBA dans le buffer utilisateur de longueur - //nRead + //Recopie le contenu de la donnée CORBA dans le buffer utilisateur de longueur nRead template static void apply( T1 * &data, T2 & corbaData, size_t nRead){ + // La ligne suivante appelle à un commentaire + // dans le cas de char *, cf CalciumPortTraits.hxx 'char *' vs 'str' typedef typename ProvidesPortTraits::PortType PortType; typedef typename PortType::DataManipulator DataManipulator; typedef typename DataManipulator::InnerType InnerType; - - size_t corbaDataSize = DataManipulator::size (corbaData); - // Récupère un pointeur sur les données contenues dans la structure CORBA sans en devenir propriétaire - InnerType * dataPtr = DataManipulator::getPointer(corbaData,false); - - // Attention : Pour les chaines ou tout autre object complexe il faut utiliser une recopie profonde ! - // Recopie des données dans le buffer allouée par l'utilisateur - // OU - // Recopie des données dans le buffer allouée la méthode appelante - // dans le cas d'une demande utilisateur 0 copie mais sur - // des types utilisateurs et CORBA incompatibles. + + #ifdef _DEBUG_ - std::cerr << "-------- Copy2UserSpace MARK 1 --(dataPtr : " < MARK 1a --dataPtr("<(std::cerr," ")); + for (int i=0; i< DataManipulator::size(corbaData); ++i) + fprintf(stderr,"pointer[%d]=%p ",i, dataPtr[i]); + std::cerr << std::endl; + + T1 * tmpData = data; + std::cerr << "-------- Copy2UserSpace MARK 1b --data("<(std::cerr," ")); + for (int i=0; i< DataManipulator::size(corbaData); ++i) + fprintf(stderr,"pointer[%d]=%p ",i, tmpData[i]); + std::cerr << std::endl; #endif + + // Pour les types pointeurs et ref il faut effectuer une recopie profonde. + // On la délègue au manipulateur de données. + + // Recopie des données dans le buffer allouée par l'utilisateur + // OU + // Recopie des données dans le buffer allouée par la méthode appelante (ex: lecture) + // dans le cas d'une demande utilisateur 0 copie mais que types utilisateurs et CORBA incompatibles. - std::copy(dataPtr,dataPtr+nRead,data); - + //std::copy(dataPtr,dataPtr+nRead,data); + DataManipulator::copy(corbaData,data,nRead); + #ifdef _DEBUG_ - std::cerr << "-------- Copy2UserSpace MARK 2 --(nRead: "< MARK 3 --(data : " <(std::cout," ")); - std::cout << std::endl; + tmpData = data; + std::cerr << "-------- Copy2UserSpace MARK 1c --data("<(std::cerr," ")); + for (int i=0; i< DataManipulator::size(corbaData); ++i) + fprintf(stderr,"pointer[%d]=%p ",i, tmpData[i]); + std::cerr << std::endl; #endif - - } + + } + }; +// Désallocation des buffers si necessaire template struct DeleteTraits { template @@ -110,18 +157,25 @@ struct DeleteTraits { //typedef typename DataManipulator::Type DataType; // Attention != T // Attention : Seul CalciumCouplingPolicy via eraseDataId doit décider de supprimer ou non - // la donnée corba associée à un DataId ! Ne pas effectuer la desallocation suivante : + // la donnée corba associée à un DataId ! + // Ne pas effectuer la desallocation suivante : // DataManipulator::relPointer(dataPtr); + // TODO : Il convient cependant de rendre la propriété du buffer à la séquence CORBA + // TODO : PB : On n'a plus de référence sur la séquence. + // TODO : Modifier l'API ecp_free pour indiquer le dataId associé ? + // TODO : ??VERIF accès concurrent à la séquence stockée ?? suppression simultanée ? + } }; -// Cas où une recopie avait été effectuée +// Désalocation du buffer intermédiaire +// dans le cas de types utilisateur/CORBA différents template <> struct DeleteTraits{ + template - static void apply(T * dataPtr) { - delete[] dataPtr; - } + static void apply(T * dataPtr) { delete[] dataPtr; } + }; #endif diff --git a/src/DSC/DSC_User/Datastream/Calcium/CorbaTypes2CalciumTypes.cxx b/src/DSC/DSC_User/Datastream/Calcium/CorbaTypes2CalciumTypes.cxx index 7c827dbb5..8ae28c91c 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CorbaTypes2CalciumTypes.cxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CorbaTypes2CalciumTypes.cxx @@ -49,11 +49,11 @@ table[Ports::Calcium_Ports::UNDEFINED_DEPENDENCY ] = CalciumTypes::UNDEFINED_DEP #ifdef _DEBUG_ -std::cout << "DEPENDENCY_TYPE() : table["<&)*this ; #ifdef _DEBUG_ -std::cout << "DEPENDENCY_TYPE() : ::operator["< + #include "Calcium_Ports.hh" #include "CalciumGenericUsesPort.hxx" diff --git a/src/DSC/DSC_User/Datastream/Calcium/calciumf.c b/src/DSC/DSC_User/Datastream/Calcium/calciumf.c index a31eda3c2..557e1ed1a 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/calciumf.c +++ b/src/DSC/DSC_User/Datastream/Calcium/calciumf.c @@ -61,6 +61,16 @@ void F_FUNC(cplen,CPLEN)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_ free_str1(cnom); } +void F_FUNC(cpllo,CPLLO)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_PSTR(nom), + int *max,int *n, int *tab,int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPLLO: %s %f %f\n",cnom,*ti,*tf); + *err=cp_llo((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab); + fprintf(stderr,"End of CPLLO: %s \n",cnom); + free_str1(cnom); +} + void F_FUNC(cpldb,CPLDB)(long *compo,int *dep,double *ti,double *tf,int *iter,STR_PSTR(nom), int *max,int *n, double *tab,int *err STR_PLEN(nom)) { @@ -81,6 +91,75 @@ void F_FUNC(cplre,CPLRE)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_ free_str1(cnom); } +void F_FUNC(cplcp,CPLCP)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_PSTR(nom), + int *max,int *n, float *tab,int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPLCP: %s %f %f \n",cnom, *ti,*tf); + *err=cp_lcp((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab); + fprintf(stderr,"End of CPLCP: %s %f %f \n",cnom,*ti,*tf); + free_str1(cnom); +} + +void F_FUNC(cplch,CPLCH)(long *compo,int *dep,float *ti,float *tf,int *iter,STR_PSTR(nom), + int *max,int *n, char *tab,int *err STR_PLEN(nom) STR_PLEN(tab) ) +{ + char **tabChaine=NULL; + int index=0; + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPLCH: %s %f %f \n",cnom, *ti,*tf); + + tabChaine = (char **) malloc(sizeof(char *) * (*max)); + for (index = 0; index < *max; index++) + tabChaine[index] = (char *) malloc(sizeof(char) * (STR_LEN(tab)+1)); + + *err=cp_lch((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tabChaine,STR_LEN(tab)); + + for (index = 0; index < *n; index++) + strcpy(&tab[index * STR_LEN(tab)], tabChaine[index]); + + fprintf(stderr,"End of CPLCH: %s %f %f \n",cnom,*ti,*tf); + if (tabChaine != (char **) NULL) { + for (index = 0; index < *n; index++) + free(tabChaine[index]); + free(tabChaine); + } + free_str1(cnom); +} + +void F_FUNC(cpech,CPECH)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom),int *n, char *tab,int *err + STR_PLEN(nom) STR_PLEN(tab)) +{ + char ** tabChaine=NULL; + int index=0,index2=0; + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPECH: %s %f \n",cnom, *ti); + + tabChaine = (char **) malloc(sizeof(char *) * *n); + for (index = 0; index < *n; index++) { + + tabChaine[index] = (char *) malloc(sizeof(char) * (STR_LEN(tab) + 1)); + strncpy(tabChaine[index],&tab[STR_LEN(tab) * index],STR_LEN(tab)); + tabChaine[index][STR_LEN(tab)]='\0'; + for (index2 = STR_LEN(tab) - 1; index2 >= 0; index2--) { + if ( tabChaine[index][index2] == ' ' || + tabChaine[index][index2] == '\0' ) + tabChaine[index][index2]='\0'; + } + } + + *err=cp_ech((void *)*compo,*dep,*ti,*iter,cnom,*n,tabChaine,STR_LEN(tab) ); + + fprintf(stderr,"End of CPECH: %s %f \n",cnom, *ti); + if (tabChaine != (char **) NULL) { + for (index = 0; index < *n; index++) + free(tabChaine[index]); + + free(tabChaine); + } + free_str1(cnom); +} + void F_FUNC(cpedb,CPEDB)(long *compo,int *dep,double *ti,int *iter,STR_PSTR(nom),int *n, double *tab,int *err STR_PLEN(nom)) { char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); @@ -99,6 +178,15 @@ void F_FUNC(cpere,CPERE)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom), free_str1(cnom); } +void F_FUNC(cpecp,CPECP)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom),int *n, float *tab,int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPECP: %s %f \n",cnom, *ti); + *err=cp_ecp((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + fprintf(stderr,"End of CPECP: %s %f \n",cnom, *ti); + free_str1(cnom); +} + void F_FUNC(cpeen,CPEEN)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom),int *n, int *tab,int *err STR_PLEN(nom)) { char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); @@ -108,6 +196,15 @@ void F_FUNC(cpeen,CPEEN)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom), free_str1(cnom); } +void F_FUNC(cpelo,CPELO)(long *compo,int *dep,float *ti,int *iter,STR_PSTR(nom),int *n, int *tab,int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + fprintf(stderr,"CPELO: %s %f %d\n",cnom, *ti,*iter); + *err=cp_elo((void *)*compo,*dep,*ti,*iter,cnom,*n,tab); + fprintf(stderr,"End of CPELO: %s %f \n",cnom,*ti); + free_str1(cnom); +} + void F_FUNC(cpfin,CPFIN)(long *compo,int *dep,int *err) { fprintf(stderr,"CPFIN: \n"); diff --git a/src/DSC/DSC_User/Datastream/CorbaTypeManipulator.hxx b/src/DSC/DSC_User/Datastream/CorbaTypeManipulator.hxx index a60cf98b3..c0adc1853 100644 --- a/src/DSC/DSC_User/Datastream/CorbaTypeManipulator.hxx +++ b/src/DSC/DSC_User/Datastream/CorbaTypeManipulator.hxx @@ -26,13 +26,13 @@ // Date : $LastChangedDate: 2007-02-07 18:26:44 +0100 (mer, 07 fév 2007) $ // Id : $Id$ -#ifndef _TYPE_MANIPULATION_HXX_ -#define _TYPE_MANIPULATION_HXX_ +#ifndef _CORBA_TYPE_MANIPULATION_HXX_ +#define _CORBA_TYPE_MANIPULATION_HXX_ #include +#include #include -using namespace std; // Classes manipulation // ------------------- @@ -48,10 +48,10 @@ using namespace std; // - delete_data // - dump // et -// deux type : -// - Type : Le type CORBA de la donnée manipulée -// - InType : Le mapping CORBA pour un paramètre IN du type manipulé - +// trois types : +// - Type : Le type CORBA de la donnée manipulée +// - InType : Le mapping CORBA pour un paramètre IN du type manipulé +// - InnerType : Type interne des valeurs d'un type contenant // Cette classe permet de manipuler des types CORBA // any, struct, union et sequence (utiliser plutôt les seq_manipulator) @@ -185,7 +185,7 @@ public: // Dump de l'objet pour deboguage : Affiche la donnee static void inline dump (CorbaInType data) { - cerr << "[atom_manipulation] Data : " << data << endl; + std::cerr << "[atom_manipulation] Data : " << data << std::endl; } }; @@ -196,11 +196,10 @@ template class seq_u_manipulation { public: - typedef seq_T * Type; - // correspond au mapping corba de la séquence en paramètre IN - typedef const seq_T & CorbaInType; - typedef elem_T InnerType; - + typedef seq_T * Type; // Type de donnée abstrait manipulé par GenericPort::Put,Get,.. + typedef const seq_T & CorbaInType; // Mapping corba de la séquence en paramètre IN + typedef elem_T InnerType; // Il n'existe pas dans CORBA de seq_T::elem_T + // C'est la raison d'être du second paramètre template de seq_u_mani // Operation de recuperation des donnees venant de l'ORB // Remarque : On a un paramètre d'entrée de type const seq_T & @@ -209,23 +208,40 @@ public: CORBA::Long len = data.length(); CORBA::Long max = data.maximum(); // Récupère et devient propriétaire des données reçues dans la séquence. - // La séquence sera désalloué (mais pas le buffer) au retour - // de la méthode put (car mapping de type IN : const seq & ) - // ATTENTION TESTER p184 si le pointeur est null - // ATTENTION TESTER Si le flag release si la sequence contient des chaines - // ou des object refs + // La séquence (mais pas le buffer) sera désallouée au retour + // de la méthode GenericPort::put (car le mapping CORBA de ce type IN est : const seq & ) + + // OLD : On ne teste pas si le flag release de la séquence est à true ou false + // OLD : ( pour des séquences de chaines ou d'objrefs ) + // OLD : -> Si on est collocalisé le port uses doit créer une copie pour éviter la modification + // OLD : du contenu de la séquence lorsque l'utilisateur modifie ses données dans son programme (0 copie) + + // Le flag release() de la séquence est à false si elle n'est pas propriétaire du buffer + // En collocalité c'est le cas (on évite ici la copie réalisée auparavant dans le port uses). + + // ATTENTION TESTER p194 si le pointeur est null (release flag==false) + // -> La séquence n'était pas propriétaire des données ! #ifdef _DEBUG_ std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1 ------------------" << std::endl; #endif - InnerType * p_data = const_cast(data).get_buffer(true); + if ( data.release() ) { + InnerType * p_data = const_cast(data).get_buffer(true); + + // Crée une nouvelle sequence propriétaire des données du buffer (pas de recopie) + // Les données de la séquence seront automatiquement désallouées par appel à la méthode freebuf + // dans le destructeur de la séquence (cf delete_data). #ifdef _DEBUG_ - std::cout << "----seq_u_manipulation::get_data(..)-- MARK 2 ------"<< p_data <<"------------" << std::endl; + std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1(0 copy) bis ------"<< p_data <<"------------" << std::endl; #endif + + return new seq_T (max, len, p_data, true); + } +#ifdef _DEBUG_ + std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1(recopie) bis ------"<< &data <<"------------" << std::endl; +#endif + // Crée une nouvelle sequence propriétaire des données du buffer (avec recopie) + return new seq_T(data); - // Crée une nouvelle sequence propriétaire des données du buffer (pas de recopie) - // Les données seront automatiquement désallouées par appel interne à la méthode freebuf - // lors de la destruction de l'objet par appel à delete_data. - return new seq_T (max, len, p_data, true); } static inline size_t size(Type data) { @@ -234,6 +250,9 @@ public: // Operation de destruction d'une donnee static inline void delete_data(Type data) { + //La séquence est détruite par appel à son destructeur + //Ce destructeur prend en compte la nécessité de détruire ou non + //les données contenues en fonction de son flag interne release() delete data; } @@ -246,9 +265,9 @@ public: return new seq_T (data); } - // Permet de désallouer le buffer dont on détient le pointeur par appel - // à la méthode getPointer avec ownerShip=True si la séquence contenante - // à été détruite. + // Permet d'obtenir un pointeur sur le buffer de la séquence + // si ownerShip=True, la séquence n'est plus propriétaire du buffer et est + // détruite (mais pas le buffer !) static inline InnerType * const getPointer(Type data, bool ownerShip = false) { InnerType * p_data; if (ownerShip) { @@ -266,12 +285,12 @@ public: seq_T::freebuf(dataPtr); } - // Permet d'allouer un buffer pour la séquence + // Permet d'allouer un buffer compatible avec le type séquence static inline InnerType * allocPointer(size_t size ) { return seq_T::allocbuf(size); } - // Operation de création du type corba soit + // Operation de création de la séquence corba soit // - Vide et de taille size // - Utilisant les données du pointeur *data de taille size // (généralement pas de recopie qlq soit l'ownership ) @@ -287,17 +306,54 @@ public: } return tmp; } + + // Copie le contenu de la séquence dans le buffer idata de taille isize + // pour les types non pointeur + template + static inline void copy( Type data, T * const idata, size_t isize ) { + + InnerType *dataPtr = getPointer(data,false); + + for (int i = 0; i< isize; ++i) + idata[i]=dataPtr[i]; + + // Ce mode de recopie ne permet pas la conversion de type (ex int -> CORBA::Long + //OLD: Type tmp = new seq_T(isize,isize,idata,false); + //OLD: // giveOwnerShip == false -> seul le contenu du buffer data est détruit et remplacé + //OLD: // par celui de data dans l'affectation suivante : + //OLD: // ---> ATTENTION SI LA TAILLE DU BUFFER EST TROP PETITE, QUE FAIT CORBA ! + //OLD: // corruption mémoire + //OLD: // Cependant ce cas devrait pas arrivé (on s'assure dans les couches supérieures + //OLD: // de la taille correcte du buffer de recopie) + //OLD: // Si giveOwnerShip était == true -> le buffer et son contenu serait détruit puis une + //OLD: // allocation de la taille du buffer de data serait effectué avant la copie des données + //OLD: // tmp = data; + } + + // Copie le contenu de la séquence de char* dans le buffer idata de taille isize + static inline void copy( Type data, char* * const idata, size_t isize ) { + + char* *dataPtr = getPointer(data,false); + + // Si idata[i] n'a pas été alloué suffisament grand, + // il y a corruption de la mémoire + for (int i = 0; i< isize; ++i) + strcpy(idata[i],dataPtr[i]); + } // Dump de l'objet pour deboguage static void inline dump (CorbaInType data) { // Affiche la longueur des donnees - cerr << "[seq_u_manipulation] Data length: " << data.length() << endl; + std::cerr << "[seq_u_manipulation] Data length: " << data.length() << std::endl; // Affiche la longueur des donnees - cerr << "[seq_u_manipulation] Data max: " << data.maximum() << endl; + std::cerr << "[seq_u_manipulation] Data max: " << data.maximum() << std::endl; } }; +// TODO : Vérifier la conformité de l'implémentation par rapport +// au type unbounded + // Gére un type sequence de taille limitée (bounded) // Ces types sont manipulés par pointeur // Cette classe diffère de la seq_u_manipulation @@ -322,11 +378,23 @@ public: // Récupère et devient propriétaire des données reçues dans la séquence // la séquence sera désalloué (mais pas le buffer) // au retour de la méthode put (car mapping de type IN : const seq & ) - InnerType * p_data = const_cast(data).get_buffer(true); + if ( data.release() ) { + InnerType * p_data = const_cast(data).get_buffer(true); + // Crée une nouvelle sequence propriétaire des données du buffer (généralement pas de recopie) // Les données seront automatiquement désallouées par appel interne à la méthode freebuf // lors de la destruction de l'objet par appel à delete_data. - return new seq_T (len, p_data, true); +#ifdef _DEBUG_ + std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1bis Pas de Duplication -----------" << std::endl; +#endif + return new seq_T (len, p_data, true); + } +#ifdef _DEBUG_ + std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1bis Duplication pour en devenir propriétaire -----------" << std::endl; +#endif + // Crée une nouvelle sequence propriétaire des données du buffer (avec recopie) + return new seq_T(data); + } static inline size_t size(Type data) { @@ -393,7 +461,7 @@ public: // Dump de l'objet pour deboguage static inline void dump (CorbaInType data) { // Affiche la longueur des donnees - cerr << "[seq_b_manipulation] Data length: " << data.length() << endl; + std::cerr << "[seq_b_manipulation] Data length: " << data.length() << std::endl; } }; diff --git a/src/DSC/DSC_User/Datastream/CouplingPolicy.hxx b/src/DSC/DSC_User/Datastream/CouplingPolicy.hxx index 0ef2b6c10..2ed03762c 100644 --- a/src/DSC/DSC_User/Datastream/CouplingPolicy.hxx +++ b/src/DSC/DSC_User/Datastream/CouplingPolicy.hxx @@ -93,7 +93,7 @@ public: // Elle profite à tous les modes de couplages n'implémentant pas // de comportement particulier dans la méthode get pour // le cas d'une demande de dataId inexistant mais encadré par deux autres - template + template struct BoundedDataIdProcessor{ BoundedDataIdProcessor(const CouplingPolicy & couplingPolicy) {}; template < typename Iterator, typename DataId > diff --git a/src/DSC/DSC_User/Datastream/GenericPort.hxx b/src/DSC/DSC_User/Datastream/GenericPort.hxx index 6148b8f8f..dd6005780 100644 --- a/src/DSC/DSC_User/Datastream/GenericPort.hxx +++ b/src/DSC/DSC_User/Datastream/GenericPort.hxx @@ -103,10 +103,12 @@ GenericPort::GenericPort() : template < typename DataManipulator, typename COUPLING_POLICY> GenericPort::~GenericPort() { typename DataTable::iterator it; - // for (it=storedDatas.begin(); it!=storedDatas.end(); ++it) { - // std::cout << "~GenericPort() : destruction de la donnnée associée au DataId :"<< (*it).first << std::endl; - // DataManipulator::delete_data( (*it).second ); - // } + for (it=storedDatas.begin(); it!=storedDatas.end(); ++it) { +#ifdef _DEBUG_ + std::cerr << "~GenericPort() : destruction de la donnnée associée au DataId :"<< (*it).first << std::endl; +#endif + DataManipulator::delete_data( (*it).second ); + } } template < typename DataManipulator, typename COUPLING_POLICY> void @@ -150,7 +152,7 @@ void GenericPort::put(CorbaInDataType dataPara try { #ifdef _DEBUG_ // Affichage des donnees pour DEBUGging - cerr << "parametres emis: " << time << ", " << tag << endl; + std::cerr << "parametres emis: " << time << ", " << tag << std::endl; DataManipulator::dump(dataParam); #endif @@ -428,21 +430,22 @@ GenericPort::get(TimeType time, // Cependant comme les données sont censées être produites // par ordre croissant de DataId, de nouvelles données ne devrait pas améliorer // l'interpolation. - // Les données calciulées sont donc stockées dans storedDatas. - // La propriété des données N'EST PAS transférée à l'utilisateur en mode CALCIUM. #ifdef _DEBUG_ std::cout << "-------- Get : MARK 8 ------------------" << std::endl; #endif - typename COUPLING_POLICY::template BoundedDataIdProcessor processBoundedDataId(*this); + typedef typename COUPLING_POLICY::template BoundedDataIdProcessor BDI; + BDI processBoundedDataId(*this); + // typename COUPLING_POLICY::template BoundedDataIdProcessor processBoundedDataId(*this); //si static BDIP::apply(dataToTransmit,expectedDataId,wDataIt1); //ancienne version template processBoundedDataId(dataToTransmit,expectedDataId,wDataIt1); //BDIP processBoundedDataId; processBoundedDataId.apply(dataToTransmit,expectedDataId,wDataIt1); // Il ne peut pas y avoir déjà une clé expectedDataId dans storedDatas (utilisation de la notation [] ) + // La nouvelle donnée produite est stockée, ce n'était pas le cas dans CALCIUM // Cette opération n'a peut être pas un caractère générique. - // A déplacer en paramètre de la méthode précédente ? + // A déplacer en paramètre de la méthode précédente ? ou déléguer ce choix au mode de couplage ? storedDatas[expectedDataId]=dataToTransmit; #ifdef _DEBUG_ diff --git a/src/DSC/DSC_User/Datastream/GenericUsesPort.hxx b/src/DSC/DSC_User/Datastream/GenericUsesPort.hxx index f6f0ce912..effed2b07 100644 --- a/src/DSC/DSC_User/Datastream/GenericUsesPort.hxx +++ b/src/DSC/DSC_User/Datastream/GenericUsesPort.hxx @@ -72,7 +72,10 @@ GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort >::Gen } template -GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort >::~GenericUsesPort() {} +GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort >::~GenericUsesPort() +{ + delete _my_ports; +} template const char * @@ -85,37 +88,34 @@ template void GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort >::put( CorbaInDataType data, - TimeType time, - TagType tag) { - typedef typename CorbaPortType::_ptr_type CorbaPortTypePtr; + TimeType time, + TagType tag) { + typedef typename CorbaPortType::_var_type CorbaPortTypeVar; if (!_my_ports) throw DSC_Exception(LOC("There is no connected provides port to communicate with.")); - // PB1 : Cf remarque dans CalciumInterface, si on n'effectue pas de copie - // du buffer ! - // PB2 : Si les ports provides auquels on envoie data sont collocalisés - // ils vont partagés le même buffer (à cause de notre optim ds get_data) - // il faut alors effectuer une copie ici. - // Pour l'instant on résoud PB2 en créant une copie de la donnée en cas - // de connexions multiples. Il faudra tester la collocalisation. - DataType copyOfData; // = data; PB1 + // OLD : PB1 : Cf remarque dans CalciumInterface, si on n'effectue pas de copie + // OLD : du buffer ! + // OLD : PB2 : Si les ports provides auquels on envoie data sont collocalisés + // OLD : ils vont partagés le même buffer (à cause de notre optim ds get_data) + // OLD : il faut alors effectuer une copie ici. + // OLD : Pour l'instant on résoud PB2 en créant une copie de la donnée en cas + // OLD : de connexions multiples. Il faudra tester la collocalisation. + // OLD : DataType copyOfData; // = data; PB1 for(int i = 0; i < _my_ports->length(); i++) { - CorbaPortTypePtr port = CorbaPortType::_narrow((*_my_ports)[i]); + CorbaPortTypeVar port = CorbaPortType::_narrow((*_my_ports)[i]); //if (i) { PB1 - copyOfData = DataManipulator::clone(data); + //OLD : copyOfData = DataManipulator::clone(data); #ifdef _DEBUG_ - std::cout << "-------- GenericUsesPort::put : Copie de data(" - //<< DataManipulator::getPointer(data) - <<") vers copyOfData (" - <put(*copyOfData,time,tag); // catcher les exceptions - } catch(const CORBA::SystemException& ex){ - DataManipulator::delete_data(copyOfData); + port->put(data,time,tag); + // OLD : port->put(*copyOfData,time,tag); + } catch(const CORBA::SystemException& ex) { + //OLD : DataManipulator::delete_data(copyOfData); throw DSC_Exception(LOC(OSS() << "Impossible d'invoquer la méthode put sur le port n°" << i << "( i>= 0)")); @@ -124,8 +124,8 @@ GenericUsesPort< DataManipulator,CorbaPortType, repositoryName, UsesPort >::put // La séquence est détruite avec le buffer si on n'est pas collocalisé // La séquence est détruite sans son buffer sinon (cf comportement de get_data // appelée dans put (port provides) - DataManipulator::delete_data(copyOfData); - } + //OLD : DataManipulator::delete_data(copyOfData); + } } @@ -138,9 +138,9 @@ GenericUsesPort< DataManipulator, CorbaPortType, repositoryName, UsesPort if (_my_ports) delete _my_ports; #ifdef _DEBUG_ - std::cerr << "GenericUsesPort::uses_port_changed" << endl; + std::cerr << "GenericUsesPort::uses_port_changed" << std::endl; #endif - _my_ports = new Engines::DSC::uses_port(*new_uses_port); + _my_ports = new_uses_port; } #endif diff --git a/src/DSC/DSC_User/Datastream/Palm/PalmCouplingPolicy.hxx b/src/DSC/DSC_User/Datastream/Palm/PalmCouplingPolicy.hxx index 30cdf27d7..c5f57fff4 100644 --- a/src/DSC/DSC_User/Datastream/Palm/PalmCouplingPolicy.hxx +++ b/src/DSC/DSC_User/Datastream/Palm/PalmCouplingPolicy.hxx @@ -29,6 +29,8 @@ #ifndef _PALM_COUPLING_POLICIES_HXX_ #define _PALM_COUPLING_POLICIES_HXX_ +#include + #include #include #include "DataIdFilter.hxx" diff --git a/src/DSC/DSC_User/Makefile.am b/src/DSC/DSC_User/Makefile.am index 42c20a9c3..7db5294da 100644 --- a/src/DSC/DSC_User/Makefile.am +++ b/src/DSC/DSC_User/Makefile.am @@ -91,6 +91,7 @@ test_DSC_Exception_SOURCES = test_DSC_Exception.cxx test_DSC_Exception_CXXFLAGS = $(COMMON_CPPFLAGS) -test_DSC_Exception_LDADD = $(top_builddir)/src/Utils/libOpUtil.la +test_DSC_Exception_LDADD = $(top_builddir)/src/Utils/libOpUtil.la \ + $(CORBA_LIBS) SUBDIRS = Basic Datastream diff --git a/src/DSC/DSC_User/Superv_Component_i.cxx b/src/DSC/DSC_User/Superv_Component_i.cxx index e94cad7c8..3f2a3e972 100644 --- a/src/DSC/DSC_User/Superv_Component_i.cxx +++ b/src/DSC/DSC_User/Superv_Component_i.cxx @@ -44,7 +44,7 @@ Superv_Component_i::Superv_Component_i(CORBA::ORB_ptr orb, Engines_DSC_i(orb, poa, contId, instanceName, interfaceName) { #ifdef _DEBUG_ - std::cout << "--Superv_Component_i : MARK 1 ---- " << instanceName << "----" << std::endl; + std::cerr << "--Superv_Component_i : MARK 1 ---- " << instanceName << "----" << std::endl; #endif register_factory("BASIC", new basic_port_factory()); register_factory("PALM", new palm_port_factory()); @@ -60,6 +60,11 @@ Superv_Component_i::~Superv_Component_i() { delete begin->second; } + + my_superv_ports_it = my_superv_ports.begin(); + for(;my_superv_ports_it != my_superv_ports.end();my_superv_ports_it++) + delete my_superv_ports_it->second; + } void @@ -155,11 +160,11 @@ Superv_Component_i::add_port(const char * port_fab_type, } else if (s_port_type == "uses") { #ifdef _DEBUG_ - std::cout << "---- Superv_Component_i::add_port : MARK 1 ---- " << std::endl; + std::cerr << "---- Superv_Component_i::add_port : MARK 1 ---- " << std::endl; #endif uses_port * port = create_uses_data_port(port_fab_type); #ifdef _DEBUG_ - std::cout << "---- Superv_Component_i::add_port : MARK 2 ---- " << std::endl; + std::cerr << "---- Superv_Component_i::add_port : MARK 2 ---- " << std::endl; #endif add_port(port, port_name); } @@ -179,9 +184,11 @@ Superv_Component_i::add_port(provides_port * port, try { - Engines_DSC_interface::add_provides_port(port->get_port_ref(), + Ports::PortProperties_var portproperties=port->get_port_properties(); + Ports::Port_var portref=port->get_port_ref(); + Engines_DSC_interface::add_provides_port(portref, provides_port_name, - port->get_port_properties()); + portproperties); superv_port_t * new_superv_port = new superv_port_t(); new_superv_port->p_ref = port; @@ -209,9 +216,10 @@ Superv_Component_i::add_port(uses_port * port, assert(uses_port_name); try { + Ports::PortProperties_var portproperties=port->get_port_properties(); Engines_DSC_interface::add_uses_port(port->get_repository_id(), uses_port_name, - port->get_port_properties()); + portproperties); superv_port_t * new_superv_port = new superv_port_t(); new_superv_port->u_ref = port; my_superv_ports[uses_port_name] = new_superv_port; @@ -236,7 +244,7 @@ Superv_Component_i::get_port(provides_port *& port, assert(provides_port_name); try { - Engines_DSC_interface::get_provides_port(provides_port_name, false); + Ports::Port_var portref=Engines_DSC_interface::get_provides_port(provides_port_name, false); port = my_superv_ports[provides_port_name]->p_ref; } catch (const Engines::DSC::PortNotDefined&) { throw PortNotDefined( LOC(OSS()<< "Le port provides " @@ -255,7 +263,8 @@ Superv_Component_i::get_port(uses_port *& port, assert(uses_port_name); try { - Engines_DSC_i::get_uses_port(uses_port_name); + Engines::DSC::uses_port * portseq=Engines_DSC_i::get_uses_port(uses_port_name); + delete portseq; port = my_superv_ports[uses_port_name]->u_ref; } catch (const Engines::DSC::PortNotDefined&) { throw PortNotDefined( LOC(OSS()<< "Le port uses " @@ -286,8 +295,10 @@ Superv_Component_i::uses_port_changed(const char* uses_port_name, { my_superv_ports_it = my_superv_ports.find(uses_port_name); if (my_superv_ports_it != my_superv_ports.end()) - my_superv_ports[uses_port_name]->u_ref->uses_port_changed(new_uses_port, + my_superv_ports[uses_port_name]->u_ref->uses_port_changed(new Engines::DSC::uses_port(*new_uses_port), message); + //delete the copy made by the caller + delete new_uses_port; } diff --git a/src/DSC/DSC_User/Superv_Component_i.hxx b/src/DSC/DSC_User/Superv_Component_i.hxx index 4bac01fc3..174380f05 100644 --- a/src/DSC/DSC_User/Superv_Component_i.hxx +++ b/src/DSC/DSC_User/Superv_Component_i.hxx @@ -32,7 +32,7 @@ #include "provides_port.hxx" #include "port_factory.hxx" -// default ports factories on the Kernel +// default ports factories in the Kernel #include "basic_port_factory.hxx" #include "palm_port_factory.hxx" #include "calcium_port_factory.hxx" @@ -263,6 +263,11 @@ private: // A Superv_Component port. struct superv_port_t { superv_port_t():u_ref(NULL),p_ref(NULL){}; + ~superv_port_t() + { + if(u_ref)delete u_ref; + if(p_ref)delete p_ref; + }; // For uses ports. uses_port * u_ref; // For provides ports. @@ -346,11 +351,12 @@ Superv_Component_i::get_port( const char * port_name) try { if ( superv_port->p_ref != NULL ) { port = superv_port->p_ref; - Engines_DSC_interface::get_provides_port(port_name, false); + Ports::Port_var portref=Engines_DSC_interface::get_provides_port(port_name, false); } else if ( superv_port->u_ref != NULL ) { port = superv_port->u_ref; - Engines_DSC_i::get_uses_port(port_name); + Engines::DSC::uses_port * portseq=Engines_DSC_i::get_uses_port(port_name); + delete portseq; } else { throw UnexpectedState( LOC(OSS()<< "Internal Error superv_port struct is inconsistent ")); diff --git a/src/KERNEL_PY/Makefile.am b/src/KERNEL_PY/Makefile.am index bd5ab0a86..3b4e96641 100755 --- a/src/KERNEL_PY/Makefile.am +++ b/src/KERNEL_PY/Makefile.am @@ -25,8 +25,8 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am -# Scripts to be installed (pkgpython is an automake keyword for python targets) -pkgpython_PYTHON = \ +# Scripts to be installed (salomepython is an automake keyword for python targets) +salomepython_PYTHON = \ Help.py \ PyInterp.py \ salome.py \ diff --git a/src/Launcher/BatchLight_BatchManager.cxx b/src/Launcher/BatchLight_BatchManager.cxx index f7bd95a5d..291f6f613 100644 --- a/src/Launcher/BatchLight_BatchManager.cxx +++ b/src/Launcher/BatchLight_BatchManager.cxx @@ -75,20 +75,19 @@ namespace BatchLight { int id; // temporary directory on cluster to put input files for job - setDirForTmpFiles(); - SCRUTE(_dirForTmpFiles); + setDirForTmpFiles(job); // export input files on cluster - exportInputFiles(job->getFileToExecute(),job->getFilesToExportList()); + exportInputFiles(job); // build salome coupling script for job - buildSalomeCouplingScript(job->getFileToExecute()); + buildSalomeCouplingScript(job); // build batch script for job - buildSalomeBatchScript(job->getNbProc()); + buildSalomeBatchScript(job); // submit job on cluster - id = submit(); + id = submit(job); // register job on map _jobmap[id] = job; @@ -96,77 +95,93 @@ namespace BatchLight { return id; } - void BatchManager::setDirForTmpFiles() + void BatchManager::setDirForTmpFiles(BatchLight::Job* job) { - int i; + std::string dirForTmpFiles; + std::string thedate; - _dirForTmpFiles = string("Batch/"); - Batch::Date date = Batch::Date(time(0)) ; - std::string thedate = date.str() ; + // Adding date to the directory name + Batch::Date date = Batch::Date(time(0)); + thedate = date.str(); int lend = thedate.size() ; - i = 0 ; + int i = 0 ; while ( i < lend ) { if ( thedate[i] == '/' || thedate[i] == '-' || thedate[i] == ':' ) { thedate[i] = '_' ; } i++ ; } - _dirForTmpFiles += thedate ; + + dirForTmpFiles += string("Batch/"); + dirForTmpFiles += thedate ; + job->setDirForTmpFiles(dirForTmpFiles); } - void BatchManager::exportInputFiles(const char *fileToExecute, const Engines::FilesList filesToExportList) throw(SALOME_Exception) + void BatchManager::exportInputFiles(BatchLight::Job* job) throw(SALOME_Exception) { BEGIN_OF("BatchManager::exportInFiles"); - string command = _params.protocol; int status; + const char * fileToExecute = job->getFileToExecute(); + const Engines::FilesList filesToExportList = job->getFilesToExportList(); + const std::string dirForTmpFiles = job->getDirForTmpFiles(); + std::string command; + std::string copy_command; + // Test protocol + if( _params.protocol == "rsh" ) + copy_command = "rcp "; + else if( _params.protocol == "ssh" ) + copy_command = "scp "; + else + throw SALOME_Exception("Unknown protocol : only rsh and ssh are known !"); + + // First step : creating batch tmp files directory + command = _params.protocol; command += " "; - if (_params.username != ""){ command += _params.username; command += "@"; } - command += _params.hostname; command += " \"mkdir -p "; - command += _dirForTmpFiles ; + command += dirForTmpFiles; command += "\"" ; SCRUTE(command.c_str()); status = system(command.c_str()); - if(status) - throw SALOME_Exception("Error of connection on remote host"); - - if( _params.protocol == "rsh" ) - command = "rcp "; - else if( _params.protocol == "ssh" ) - command = "scp "; - else - throw SALOME_Exception("Unknown protocol"); + if(status) { + std::ostringstream oss; + oss << status; + std::string ex_mess("Error of connection on remote host ! status = "); + ex_mess += oss.str(); + throw SALOME_Exception(ex_mess.c_str()); + } + // Second step : copy fileToExecute into + // batch tmp files directory + command = copy_command; command += fileToExecute; command += " "; - if (_params.username != ""){ command += _params.username; command += "@"; } - command += _params.hostname; command += ":"; - command += _dirForTmpFiles ; + command += dirForTmpFiles; SCRUTE(command.c_str()); status = system(command.c_str()); - if(status) - throw SALOME_Exception("Error of connection on remote host"); + if(status) { + std::ostringstream oss; + oss << status; + std::string ex_mess("Error of connection on remote host ! status = "); + ex_mess += oss.str(); + throw SALOME_Exception(ex_mess.c_str()); + } - int i ; - for ( i = 0 ; i < filesToExportList.length() ; i++ ) { - if( _params.protocol == "rsh" ) - command = "rcp "; - else if( _params.protocol == "ssh" ) - command = "scp "; - else - throw SALOME_Exception("Unknown protocol"); + // Third step : copy filesToExportList into + // batch tmp files directory + for (int i = 0 ; i < filesToExportList.length() ; i++ ) { + command = copy_command; command += filesToExportList[i] ; command += " "; if (_params.username != ""){ @@ -175,11 +190,16 @@ namespace BatchLight { } command += _params.hostname; command += ":"; - command += _dirForTmpFiles ; + command += dirForTmpFiles ; SCRUTE(command.c_str()); status = system(command.c_str()); - if(status) - throw SALOME_Exception("Error of connection on remote host"); + if(status) { + std::ostringstream oss; + oss << status; + std::string ex_mess("Error of connection on remote host ! status = "); + ex_mess += oss.str(); + throw SALOME_Exception(ex_mess.c_str()); + } } END_OF("BatchManager::exportInFiles"); @@ -212,8 +232,16 @@ namespace BatchLight { command += directory; SCRUTE(command.c_str()); status = system(command.c_str()); - if(status) - throw SALOME_Exception("Error of connection on remote host"); + if(status) + { + // Try to get what we can (logs files) + // throw SALOME_Exception("Error of connection on remote host"); + std::string mess("Copy command failed ! status is :"); + ostringstream status_str; + status_str << status; + mess += status_str.str(); + INFOS(mess); + } } END_OF("BatchManager::importOutputFiles"); @@ -226,10 +254,8 @@ namespace BatchLight { strcpy(temp, "/tmp/command"); strcat(temp, "XXXXXX"); #ifndef WNT - mkstemp(temp); #else - char aPID[80]; itoa( _getpid(), aPID, 10); strcat(temp, aPID); @@ -241,18 +267,16 @@ namespace BatchLight { return command; } - void BatchManager::RmTmpFile() + void BatchManager::RmTmpFile(std::string & TemporaryFileName) { - if (_TmpFileName != ""){ - string command = "rm "; - command += _TmpFileName; - char *temp = strdup(command.c_str()); - int lgthTemp = strlen(temp); - temp[lgthTemp - 3] = '*'; - temp[lgthTemp - 2] = '\0'; - system(temp); - free(temp); - } + string command = "rm "; + command += TemporaryFileName; + char *temp = strdup(command.c_str()); + int lgthTemp = strlen(temp); + temp[lgthTemp - 3] = '*'; + temp[lgthTemp - 2] = '\0'; + system(temp); + free(temp); } MpiImpl *BatchManager::FactoryMpiImpl(string mpiImpl) throw(SALOME_Exception) diff --git a/src/Launcher/BatchLight_BatchManager.hxx b/src/Launcher/BatchLight_BatchManager.hxx index a8ea0061a..7183c1d1b 100644 --- a/src/Launcher/BatchLight_BatchManager.hxx +++ b/src/Launcher/BatchLight_BatchManager.hxx @@ -69,22 +69,17 @@ namespace BatchLight { protected: batchParams _params; MpiImpl *_mpiImpl; - std::map _jobmap; - std::string _dirForTmpFiles; // repertoire temporaire sur le serveur - std::string _TmpFileName; - std::string _fileNameToExecute; - virtual int submit() throw(SALOME_Exception) = 0; - void setDirForTmpFiles(); - void exportInputFiles( const char *fileToExecute, const Engines::FilesList filesToExportList ) throw(SALOME_Exception); - virtual void buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception) = 0; - virtual void buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception) = 0; + virtual int submit(BatchLight::Job* job) throw(SALOME_Exception) = 0; + void setDirForTmpFiles(BatchLight::Job* job); + void exportInputFiles(BatchLight::Job* job) throw(SALOME_Exception); + virtual void buildSalomeCouplingScript(BatchLight::Job* job) throw(SALOME_Exception) = 0; + virtual void buildSalomeBatchScript(BatchLight::Job* job) throw(SALOME_Exception) = 0; std::string BuildTemporaryFileName() const; - void RmTmpFile(); + void RmTmpFile(std::string & TemporaryFileName); MpiImpl *FactoryMpiImpl(std::string mpiImpl) throw(SALOME_Exception); - private: }; diff --git a/src/Launcher/BatchLight_BatchManager_PBS.cxx b/src/Launcher/BatchLight_BatchManager_PBS.cxx index 15241abff..cd02df56b 100644 --- a/src/Launcher/BatchLight_BatchManager_PBS.cxx +++ b/src/Launcher/BatchLight_BatchManager_PBS.cxx @@ -100,10 +100,11 @@ namespace BatchLight { logFile += getenv("USER"); logFile += "/batchSalome_"; - srand ( time(NULL) ); - int ir = rand(); + //srand ( time(NULL) ); + //int ir = rand(); ostringstream oss; - oss << ir; + //oss << ir; + oss << this << "_" << jobid; logFile += oss.str(); logFile += ".log"; @@ -125,9 +126,10 @@ namespace BatchLight { command += _params.hostname; command += " \"qstat -f " ; - ostringstream oss2; - oss2 << jobid; - command += oss2.str(); + //ostringstream oss2; + //oss2 << jobid; + //command += oss2.str(); + command += _pbs_job_name[jobid]; command += "\" > "; command += logFile; SCRUTE(command.c_str()); @@ -167,35 +169,73 @@ namespace BatchLight { return jstatus; } - void BatchManager_PBS::buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception) + void BatchManager_PBS::buildSalomeCouplingScript(BatchLight::Job* job) throw(SALOME_Exception) { BEGIN_OF("BatchManager_PBS::buildSalomeCouplingScript"); int status; + const char *fileToExecute = job->getFileToExecute(); + const std::string dirForTmpFiles = job->getDirForTmpFiles(); + int idx = dirForTmpFiles.find("Batch/"); + std::string filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); string::size_type p1 = string(fileToExecute).find_last_of("/"); string::size_type p2 = string(fileToExecute).find_last_of("."); - _fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1); + std::string fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1); + std::string TmpFileName = BuildTemporaryFileName(); - _TmpFileName = BuildTemporaryFileName(); ofstream tempOutputFile; - tempOutputFile.open(_TmpFileName.c_str(), ofstream::out ); + tempOutputFile.open(TmpFileName.c_str(), ofstream::out ); + + // Begin tempOutputFile << "#! /bin/sh -f" << endl ; tempOutputFile << "cd " ; tempOutputFile << _params.applipath << endl ; + tempOutputFile << "export SALOME_BATCH=1\n"; tempOutputFile << "export PYTHONPATH=~/" ; - tempOutputFile << _dirForTmpFiles ; + tempOutputFile << dirForTmpFiles ; tempOutputFile << ":$PYTHONPATH" << endl ; + + // Test node rank tempOutputFile << "if test " ; tempOutputFile << _mpiImpl->rank() ; tempOutputFile << " = 0; then" << endl ; + + // ----------------------------------------------- + // Code for rank 0 : launch runAppli and a container + // RunAppli tempOutputFile << " ./runAppli --terminal --modules=" ; for ( int i = 0 ; i < _params.modulesList.size() ; i++ ) { tempOutputFile << _params.modulesList[i] ; if ( i != _params.modulesList.size()-1 ) tempOutputFile << "," ; } - tempOutputFile << " --standalone=registry,study,moduleCatalog --killall &" << endl ; - tempOutputFile << " for ((ip=1; ip < "; + tempOutputFile << " --standalone=registry,study,moduleCatalog --ns-port-log=" + << filelogtemp + << " &\n"; + + // Wait NamingService + tempOutputFile << " current=0\n" + << " stop=20\n" + << " while ! test -f " << filelogtemp << "\n" + << " do\n" + << " sleep 2\n" + << " let current=current+1\n" + << " if [ \"$current\" -eq \"$stop\" ] ; then\n" + << " echo Error Naming Service failed ! >&2" + << " exit\n" + << " fi\n" + << " done\n" + << " port=`cat " << filelogtemp << "`\n"; + + // Launch a container + tempOutputFile << " ./runSession SALOME_Container 'YACS_Server_'" + << _mpiImpl->rank() + << " > ~/" << dirForTmpFiles << "/YACS_Server_" + << _mpiImpl->rank() << "_container_log." << filelogtemp + << " 2>&1 &\n"; + + // Wait other containers + tempOutputFile << " for ((ip=0; ip < "; tempOutputFile << _mpiImpl->size(); tempOutputFile << " ; ip++))" << endl; tempOutputFile << " do" << endl ; @@ -203,14 +243,39 @@ namespace BatchLight { tempOutputFile << " done" << endl ; tempOutputFile << " sleep 5" << endl ; tempOutputFile << " ./runSession waitContainers.py $arglist" << endl ; - tempOutputFile << " ./runSession python ~/" << _dirForTmpFiles << "/" << _fileNameToExecute << ".py" << endl; - tempOutputFile << " ./runSession killCurrentPort" << endl; + + // Launch user script + tempOutputFile << " ./runSession python ~/" << dirForTmpFiles << "/" << fileNameToExecute << ".py\n"; + + // Stop application + tempOutputFile << " rm " << filelogtemp << "\n" + << " ./runSession killSalomeWithPort.py $port\n"; + + // ------------------------------------- + // Other nodes launch a container tempOutputFile << "else" << endl ; - tempOutputFile << " sleep 5" << endl ; - tempOutputFile << " ./runSession waitNS.py" << endl ; + + // Wait NamingService + tempOutputFile << " current=0\n" + << " stop=20\n" + << " while ! test -f " << filelogtemp << "\n" + << " do\n" + << " sleep 2\n" + << " let current=current+1\n" + << " if [ \"$current\" -eq \"$stop\" ] ; then\n" + << " echo Error Naming Service failed ! >&2" + << " exit\n" + << " fi\n" + << " done\n" + << " port=`cat " << filelogtemp << "`\n"; + + // Launching container tempOutputFile << " ./runSession SALOME_Container 'YACS_Server_'"; - tempOutputFile << _mpiImpl->rank() << endl ; - tempOutputFile << "fi" << endl ; + tempOutputFile << _mpiImpl->rank() + << " > ~/" << dirForTmpFiles << "/YACS_Server_" + << _mpiImpl->rank() << "_container_log." << filelogtemp + << " 2>&1\n"; + tempOutputFile << "fi" << endl; tempOutputFile.flush(); tempOutputFile.close(); #ifdef WNT @@ -218,8 +283,8 @@ namespace BatchLight { #else chmod #endif - (_TmpFileName.c_str(), 0x1ED); - SCRUTE(_TmpFileName.c_str()) ; + (TmpFileName.c_str(), 0x1ED); + SCRUTE(TmpFileName.c_str()) ; string command; if( _params.protocol == "rsh" ) @@ -229,7 +294,7 @@ namespace BatchLight { else throw SALOME_Exception("Unknown protocol"); - command += _TmpFileName; + command += TmpFileName; command += " "; if (_params.username != ""){ command += _params.username; @@ -237,24 +302,34 @@ namespace BatchLight { } command += _params.hostname; command += ":"; - command += _dirForTmpFiles ; + command += dirForTmpFiles ; command += "/runSalome_" ; - command += _fileNameToExecute ; + command += fileNameToExecute ; command += "_Batch.sh" ; - SCRUTE(_fileNameToExecute) ; + SCRUTE(fileNameToExecute) ; SCRUTE(command.c_str()); status = system(command.c_str()); if(status) throw SALOME_Exception("Error of connection on remote host"); - RmTmpFile(); + RmTmpFile(TmpFileName); END_OF("BatchManager_PBS::buildSalomeCouplingScript"); } - void BatchManager_PBS::buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception) + void BatchManager_PBS::buildSalomeBatchScript(BatchLight::Job* job) throw(SALOME_Exception) { BEGIN_OF("BatchManager_PBS::buildSalomeBatchScript"); int status; + const int nbproc = job->getNbProc(); + std::string edt = job->getExpectedDuringTime(); + std::string mem = job->getMemory(); + const std::string dirForTmpFiles = job->getDirForTmpFiles(); + const char *fileToExecute = job->getFileToExecute(); + string::size_type p1 = string(fileToExecute).find_last_of("/"); + string::size_type p2 = string(fileToExecute).find_last_of("."); + std::string fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1); + int idx = dirForTmpFiles.find("Batch/"); + std::string filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); int nbmaxproc = _params.nbnodes * _params.nbprocpernode; if( nbproc > nbmaxproc ){ @@ -268,16 +343,25 @@ namespace BatchLight { else nbnodes = _params.nbnodes; - _TmpFileName = BuildTemporaryFileName(); + std::string TmpFileName = BuildTemporaryFileName(); ofstream tempOutputFile; - tempOutputFile.open(_TmpFileName.c_str(), ofstream::out ); + tempOutputFile.open(TmpFileName.c_str(), ofstream::out ); ostringstream filenameToExecute; - filenameToExecute << " ~/" << _dirForTmpFiles << "/runSalome_" << _fileNameToExecute << "_Batch.sh"; + filenameToExecute << " ~/" << dirForTmpFiles << "/runSalome_" << fileNameToExecute << "_Batch.sh"; tempOutputFile << "#! /bin/sh -f" << endl ; tempOutputFile << "#PBS -l nodes=" << nbnodes << endl ; - tempOutputFile << "#PBS -o ~/" << _dirForTmpFiles << "/runSalome.log${PBS_JOBID}" << endl ; + if (edt != "") + tempOutputFile << "#PBS -l walltime=" << edt << ":00" << endl ; + if (mem != "") + tempOutputFile << "#PBS -l mem=" << mem << endl ; + // In some systems qsub does not correctly expand env variables + // like PBS_O_HOME for #PBS directives.... + //tempOutputFile << "#PBS -o /$PBS_O_HOME/" << dirForTmpFiles << "/runSalome.output.log.${PBS_JOBID}" << endl ; + //tempOutputFile << "#PBS -e /$PBS_O_HOME/" << dirForTmpFiles << "/runSalome.error.log.${PBS_JOBID}" << endl ; + tempOutputFile << "#PBS -o runSalome.output.log." << filelogtemp << endl ; + tempOutputFile << "#PBS -e runSalome.error.log." << filelogtemp << endl ; tempOutputFile << _mpiImpl->boot("${PBS_NODEFILE}",nbnodes); tempOutputFile << _mpiImpl->run("${PBS_NODEFILE}",nbproc,filenameToExecute.str()); tempOutputFile << _mpiImpl->halt(); @@ -288,8 +372,8 @@ namespace BatchLight { #else chmod #endif - (_TmpFileName.c_str(), 0x1ED); - SCRUTE(_TmpFileName.c_str()) ; + (TmpFileName.c_str(), 0x1ED); + SCRUTE(TmpFileName.c_str()) ; string command; if( _params.protocol == "rsh" ) @@ -298,7 +382,7 @@ namespace BatchLight { command = "scp "; else throw SALOME_Exception("Unknown protocol"); - command += _TmpFileName; + command += TmpFileName; command += " "; if (_params.username != ""){ command += _params.username; @@ -306,23 +390,37 @@ namespace BatchLight { } command += _params.hostname; command += ":"; - command += _dirForTmpFiles ; + command += dirForTmpFiles ; command += "/" ; - command += _fileNameToExecute ; + command += fileNameToExecute ; command += "_Batch.sh" ; SCRUTE(command.c_str()); status = system(command.c_str()); if(status) throw SALOME_Exception("Error of connection on remote host"); - - RmTmpFile(); + + // Adding log files into import list files + ostringstream file_name_output; + file_name_output << "~/" << dirForTmpFiles << "/" << "runSalome.output.log*"; + ostringstream file_name_error; + file_name_error << "~/" << dirForTmpFiles << "/" << "runSalome.error.log*"; + ostringstream file_container_log; + file_container_log << "~/" << dirForTmpFiles << "/" << "YACS_Server*"; + job->addFileToImportList(file_name_output.str()); + job->addFileToImportList(file_name_error.str()); + job->addFileToImportList(file_container_log.str()); + RmTmpFile(TmpFileName); END_OF("BatchManager_PBS::buildSalomeBatchScript"); - } - int BatchManager_PBS::submit() throw(SALOME_Exception) + int BatchManager_PBS::submit(BatchLight::Job* job) throw(SALOME_Exception) { BEGIN_OF("BatchManager_PBS::submit"); + const std::string dirForTmpFiles = job->getDirForTmpFiles(); + const char *fileToExecute = job->getFileToExecute(); + string::size_type p1 = string(fileToExecute).find_last_of("/"); + string::size_type p2 = string(fileToExecute).find_last_of("."); + std::string fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1); // define name of log file string logFile="/tmp/logs/"; @@ -353,10 +451,10 @@ namespace BatchLight { } command += _params.hostname; - command += " \"qsub " ; - command += _dirForTmpFiles ; - command += "/" ; - command += _fileNameToExecute ; + command += " \"cd " ; + command += dirForTmpFiles; + command += "; qsub " ; + command += fileNameToExecute ; command += "_Batch.sh\" > "; command += logFile; SCRUTE(command.c_str()); @@ -382,6 +480,8 @@ namespace BatchLight { istringstream iss(strjob); iss >> id; + // Ajout dans la map + _pbs_job_name[id] = sline; END_OF("BatchManager_PBS::submit"); return id; } diff --git a/src/Launcher/BatchLight_BatchManager_PBS.hxx b/src/Launcher/BatchLight_BatchManager_PBS.hxx index e7e5789c7..e0c21651b 100644 --- a/src/Launcher/BatchLight_BatchManager_PBS.hxx +++ b/src/Launcher/BatchLight_BatchManager_PBS.hxx @@ -49,9 +49,14 @@ namespace BatchLight { std::string queryJob(const int & jobid); // renvoie l'etat du job private: - void buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception); - void buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception); - int submit() throw(SALOME_Exception); + void buildSalomeCouplingScript(BatchLight::Job* job) throw(SALOME_Exception); + void buildSalomeBatchScript(BatchLight::Job* job) throw(SALOME_Exception); + int submit(BatchLight::Job* job) throw(SALOME_Exception); + + // Permet d'avoir la chaîne complête pour demander + // le statut du job + typedef std::map _pbs_job_name_t; + _pbs_job_name_t _pbs_job_name; }; } diff --git a/src/Launcher/BatchLight_BatchManager_SLURM.cxx b/src/Launcher/BatchLight_BatchManager_SLURM.cxx index ee17d2c8b..ac91a28ba 100644 --- a/src/Launcher/BatchLight_BatchManager_SLURM.cxx +++ b/src/Launcher/BatchLight_BatchManager_SLURM.cxx @@ -147,23 +147,25 @@ namespace BatchLight { return jstatus; } - void BatchManager_SLURM::buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception) + void BatchManager_SLURM::buildSalomeCouplingScript(BatchLight::Job* job) throw(SALOME_Exception) { BEGIN_OF("BatchManager_SLURM::buildSalomeCouplingScript"); int status; + const char *fileToExecute = job->getFileToExecute(); + const std::string dirForTmpFiles = job->getDirForTmpFiles(); string::size_type p1 = string(fileToExecute).find_last_of("/"); string::size_type p2 = string(fileToExecute).find_last_of("."); - _fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1); + std::string fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1); - _TmpFileName = BuildTemporaryFileName(); + std::string TmpFileName = BuildTemporaryFileName(); ofstream tempOutputFile; - tempOutputFile.open(_TmpFileName.c_str(), ofstream::out ); + tempOutputFile.open(TmpFileName.c_str(), ofstream::out ); tempOutputFile << "#! /bin/sh -f" << endl ; tempOutputFile << "cd " ; tempOutputFile << _params.applipath << endl ; tempOutputFile << "export PYTHONPATH=~/" ; - tempOutputFile << _dirForTmpFiles ; + tempOutputFile << dirForTmpFiles ; tempOutputFile << ":$PYTHONPATH" << endl ; tempOutputFile << "if test $SLURM_PROCID = 0; then" << endl ; tempOutputFile << " ./runAppli --terminal --modules=" ; @@ -179,7 +181,7 @@ namespace BatchLight { tempOutputFile << " done" << endl ; tempOutputFile << " ./runSession waitNS.sh" << endl ; tempOutputFile << " ./runSession waitContainers.py $arglist" << endl ; - tempOutputFile << " ./runSession python ~/" << _dirForTmpFiles << "/" << _fileNameToExecute << ".py" << endl; + tempOutputFile << " ./runSession python ~/" << dirForTmpFiles << "/" << fileNameToExecute << ".py" << endl; tempOutputFile << " ./runSession killCurrentPort" << endl; tempOutputFile << "else" << endl ; tempOutputFile << " ./runSession waitNS.sh" << endl ; @@ -192,9 +194,9 @@ namespace BatchLight { #else chmod #endif - (_TmpFileName.c_str(), 0x1ED); + (TmpFileName.c_str(), 0x1ED); - SCRUTE(_TmpFileName.c_str()) ; + SCRUTE(TmpFileName.c_str()) ; string command; if( _params.protocol == "rsh" ) @@ -204,7 +206,7 @@ namespace BatchLight { else throw SALOME_Exception("Unknown protocol"); - command += _TmpFileName; + command += TmpFileName; command += " "; if (_params.username != ""){ command += _params.username; @@ -212,35 +214,41 @@ namespace BatchLight { } command += _params.hostname; command += ":"; - command += _dirForTmpFiles ; + command += dirForTmpFiles ; command += "/runSalome_" ; - command += _fileNameToExecute ; + command += fileNameToExecute ; command += "_Batch.sh" ; SCRUTE(command.c_str()); status = system(command.c_str()); if(status) throw SALOME_Exception("Error of connection on remote host"); - RmTmpFile(); + RmTmpFile(TmpFileName); END_OF("BatchManager_SLURM::buildSalomeCouplingScript"); } - void BatchManager_SLURM::buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception) + void BatchManager_SLURM::buildSalomeBatchScript(BatchLight::Job* job) throw(SALOME_Exception) { BEGIN_OF("BatchManager_SLURM::buildSalomeBatchScript"); int status; - _TmpFileName = BuildTemporaryFileName(); + const int nbproc = job->getNbProc(); + const std::string dirForTmpFiles = job->getDirForTmpFiles(); + std::string TmpFileName = BuildTemporaryFileName(); ofstream tempOutputFile; - tempOutputFile.open(_TmpFileName.c_str(), ofstream::out ); + tempOutputFile.open(TmpFileName.c_str(), ofstream::out ); + const char *fileToExecute = job->getFileToExecute(); + string::size_type p1 = string(fileToExecute).find_last_of("/"); + string::size_type p2 = string(fileToExecute).find_last_of("."); + std::string fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1); tempOutputFile << "#! /bin/sh -f" << endl ; tempOutputFile << "#BSUB -n " << nbproc << endl ; - tempOutputFile << "#BSUB -o " << _dirForTmpFiles << "/runSalome.log%J" << endl ; - tempOutputFile << "mpirun -srun ~/" << _dirForTmpFiles << "/runSalome_" << _fileNameToExecute << "_Batch.sh" << endl ; + tempOutputFile << "#BSUB -o " << dirForTmpFiles << "/runSalome.log%J" << endl ; + tempOutputFile << "srun ~/" << dirForTmpFiles << "/runSalome_" << fileNameToExecute << "_Batch.sh" << endl ; tempOutputFile.flush(); tempOutputFile.close(); - chmod(_TmpFileName.c_str(), 0x1ED); - SCRUTE(_TmpFileName.c_str()) ; + chmod(TmpFileName.c_str(), 0x1ED); + SCRUTE(TmpFileName.c_str()) ; string command; if( _params.protocol == "rsh" ) @@ -249,7 +257,7 @@ namespace BatchLight { command = "scp "; else throw SALOME_Exception("Unknown protocol"); - command += _TmpFileName; + command += TmpFileName; command += " "; if (_params.username != ""){ command += _params.username; @@ -257,23 +265,28 @@ namespace BatchLight { } command += _params.hostname; command += ":"; - command += _dirForTmpFiles ; + command += dirForTmpFiles ; command += "/" ; - command += _fileNameToExecute ; + command += fileNameToExecute ; command += "_Batch.sh" ; SCRUTE(command.c_str()); status = system(command.c_str()); if(status) throw SALOME_Exception("Error of connection on remote host"); - RmTmpFile(); + RmTmpFile(TmpFileName); END_OF("BatchManager_SLURM::buildSalomeBatchScript"); } - int BatchManager_SLURM::submit() throw(SALOME_Exception) + int BatchManager_SLURM::submit(BatchLight::Job* job) throw(SALOME_Exception) { BEGIN_OF("BatchManager_SLURM::submit"); + const std::string dirForTmpFiles = job->getDirForTmpFiles(); + const char *fileToExecute = job->getFileToExecute(); + string::size_type p1 = string(fileToExecute).find_last_of("/"); + string::size_type p2 = string(fileToExecute).find_last_of("."); + std::string fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1); // define name of log file string logFile="/tmp/logs/"; @@ -305,9 +318,9 @@ namespace BatchLight { command += _params.hostname; command += " \"bsub < " ; - command += _dirForTmpFiles ; + command += dirForTmpFiles ; command += "/" ; - command += _fileNameToExecute ; + command += fileNameToExecute ; command += "_Batch.sh\" > "; command += logFile; SCRUTE(command.c_str()); @@ -322,9 +335,9 @@ namespace BatchLight { fclose(fp); string sline(line); - int p1 = sline.find("<"); - int p2 = sline.find(">"); - string strjob = sline.substr(p1+1,p2-p1-1); + int p10 = sline.find("<"); + int p20 = sline.find(">"); + string strjob = sline.substr(p10+1,p20-p10-1); int id; istringstream iss(strjob); diff --git a/src/Launcher/BatchLight_BatchManager_SLURM.hxx b/src/Launcher/BatchLight_BatchManager_SLURM.hxx index ed21624dd..6024b28de 100644 --- a/src/Launcher/BatchLight_BatchManager_SLURM.hxx +++ b/src/Launcher/BatchLight_BatchManager_SLURM.hxx @@ -49,9 +49,9 @@ namespace BatchLight { std::string queryJob(const int & jobid); // renvoie l'etat du job protected: - void buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception); - void buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception); - int submit() throw(SALOME_Exception); + void buildSalomeCouplingScript(BatchLight::Job* job) throw(SALOME_Exception); + void buildSalomeBatchScript(BatchLight::Job* job) throw(SALOME_Exception); + int submit(BatchLight::Job* job) throw(SALOME_Exception); private: diff --git a/src/Launcher/BatchLight_Job.cxx b/src/Launcher/BatchLight_Job.cxx index 9762a98a6..1980054a9 100644 --- a/src/Launcher/BatchLight_Job.cxx +++ b/src/Launcher/BatchLight_Job.cxx @@ -27,19 +27,134 @@ */ #include "BatchLight_Job.hxx" +#include + using namespace std; +using namespace BatchLight; + +Job::Job(const char *fileToExecute, + const Engines::FilesList& filesToExport, + const Engines::FilesList& filesToImport, + const Engines::BatchParameters& batch_params) : _fileToExecute(fileToExecute), + _filesToExport(filesToExport), + _filesToImport(filesToImport), + _batch_params(batch_params) +{ + _dirForTmpFiles = "/tmp/default_batch_tmp_directory"; + std::string _fileNameToExecute = ""; +} + +Job::~Job() +{ + MESSAGE("Job destructor"); +} + +void +Job::addFileToImportList(std::string file_name) +{ + CORBA::ULong lgth = _filesToImport.length(); + _filesToImport.length(lgth+1); + _filesToImport[lgth] = CORBA::string_dup(file_name.c_str()); +} + +const std::string +Job::getExpectedDuringTime() +{ + std::string str(_batch_params.expected_during_time); + return str; +} + +const std::string +Job::getMemory() +{ + std::string str(_batch_params.mem); + return str; +} + +bool +Job::check() { + bool rtn = true; + INFOS("Warning : batch_directory option is not currently implemented"); + INFOS("Warning : currently these informations are only in the PBS batch manager"); + INFOS("Job parameters are :"); + INFOS("Directory : $HOME/Batch/$date"); -namespace BatchLight { + // check expected_during_time (check the format) + std::string edt_info; + std::string edt_value = _batch_params.expected_during_time.in(); + if (edt_value != "") { + std::string begin_edt_value = edt_value.substr(0, 2); + std::string mid_edt_value = edt_value.substr(2, 1); + std::string end_edt_value = edt_value.substr(3); + + long value; + std::istringstream iss(begin_edt_value); + if (!(iss >> value)) { + edt_info = "Error on definition ! : " + edt_value; + rtn = false; + } + else if (value < 0) { + edt_info = "Error on definition time is negative ! : " + value; + rtn = false; + } + std::istringstream iss_2(end_edt_value); + if (!(iss_2 >> value)) { + edt_info = "Error on definition ! : " + edt_value; + rtn = false; + } + else if (value < 0) { + edt_info = "Error on definition time is negative ! : " + value; + rtn = false; + } + if (mid_edt_value != ":") { + edt_info = "Error on definition ! :" + edt_value; + rtn = false; + } + } + else { + edt_info = "No value given"; + } + INFOS("Expected during time : " << edt_info); - // Constructeur - Job::Job(const char *fileToExecute, const Engines::FilesList& filesToExport, const Engines::FilesList& filesToImport, const int nbproc) : _fileToExecute(fileToExecute), _filesToExport(filesToExport), _filesToImport(filesToImport), _nbproc(nbproc) - { - // Nothing to do + // check memory (check the format) + std::string mem_info; + std::string mem_value = _batch_params.mem.in(); + if (mem_value != "") { + std::string begin_mem_value = mem_value.substr(0, mem_value.length()-2); + long re_mem_value; + std::istringstream iss(begin_mem_value); + if (!(iss >> re_mem_value)) { + mem_info = "Error on definition ! : " + mem_value; + rtn = false; + } + else if (re_mem_value <= 0) { + mem_info = "Error on definition memory is negative ! : " + mem_value; + rtn = false; + } + std::string end_mem_value = mem_value.substr(mem_value.length()-2); + if (end_mem_value != "gb" and end_mem_value != "mb") { + mem_info = "Error on definition, type is bad ! " + mem_value; + rtn = false; + } } + else { + mem_info = "No value given"; + } + INFOS("Memory : " << mem_info); - Job::~Job() - { - MESSAGE("Job destructor"); + // check nb_proc + std::string nb_proc_info; + ostringstream nb_proc_value; + nb_proc_value << _batch_params.nb_proc; + if(_batch_params.nb_proc <= 0) { + nb_proc_info = "Bad value ! nb_proc = "; + nb_proc_info += nb_proc_value.str(); + rtn = false; + } + else { + nb_proc_info = nb_proc_value.str(); } + INFOS("Nb of processors : " << nb_proc_info); + return rtn; } diff --git a/src/Launcher/BatchLight_Job.hxx b/src/Launcher/BatchLight_Job.hxx index 23ac8f3bb..e17e790b9 100644 --- a/src/Launcher/BatchLight_Job.hxx +++ b/src/Launcher/BatchLight_Job.hxx @@ -39,20 +39,30 @@ namespace BatchLight { { public: // Constructeurs et destructeur - Job(const char *fileToExecute, const Engines::FilesList& filesToExport, const Engines::FilesList& filesToImport, const int nbproc); + Job(const char *fileToExecute, + const Engines::FilesList& filesToExport, + const Engines::FilesList& filesToImport, + const Engines::BatchParameters& batch_params); virtual ~Job(); const char *getFileToExecute() const { return _fileToExecute; } const Engines::FilesList getFilesToExportList() const { return _filesToExport; } const Engines::FilesList getFilesToImportList() const { return _filesToImport; } - const int getNbProc() const { return _nbproc; } - + void addFileToImportList(std::string file_name); + const CORBA::Long getNbProc() const { return _batch_params.nb_proc; } + const std::string getExpectedDuringTime(); + const std::string getMemory(); + + const std::string getDirForTmpFiles() const { return _dirForTmpFiles;} + void setDirForTmpFiles(std::string dirForTmpFiles) {_dirForTmpFiles = dirForTmpFiles; + SCRUTE(_dirForTmpFiles);} + bool check(); protected: const char* _fileToExecute; const Engines::FilesList _filesToExport; - const Engines::FilesList _filesToImport; - const int _nbproc; - + Engines::FilesList _filesToImport; + Engines::BatchParameters _batch_params; + std::string _dirForTmpFiles; // Tmp directory on the server private: }; diff --git a/src/Launcher/Makefile.am b/src/Launcher/Makefile.am index b0323d754..a78dc3edb 100644 --- a/src/Launcher/Makefile.am +++ b/src/Launcher/Makefile.am @@ -84,12 +84,11 @@ COMMON_LIBS =\ ../SALOMELocalTrace/libSALOMELocalTrace.la \ ../Basics/libSALOMEBasics.la \ ../Batch/libSalomeBatch.la \ - $(top_builddir)/idl/libSalomeIDLKernel.la\ + $(top_builddir)/idl/libSalomeIDLKernel.la \ @MPI_LIBS@ \ - @CORBA_LIBS@ - @LIBXML_LIBS@ - -# @PYTHON_LIBS@ + @CORBA_LIBS@ \ + @LIBXML_LIBS@ \ + @PYTHON_LIBS@ # # =============================================================== @@ -113,7 +112,6 @@ libSalomeLauncher_la_LDFLAGS =\ @LDEXPDYNFLAGS@ libSalomeLauncher_la_LIBADD =\ - $(PYTHON_LIBS) \ $(COMMON_LIBS) @@ -132,8 +130,9 @@ SALOME_LauncherServer_CPPFLAGS=\ SALOME_LauncherServer_LDADD =\ libSalomeLauncher.la \ - $(COMMON_LIBS) \ - ../Basics/libSALOMEBasics.la \ - ../Batch/libSalomeBatch.la + $(MPI_LIBS) \ + $(CORBA_LIBS) \ + $(LIBXML_LIBS) \ + $(PYTHON_LIBS) diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index fb077df12..48facc1af 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -127,7 +127,7 @@ CORBA::Long SALOME_Launcher::getPID() CORBA::Long SALOME_Launcher::submitSalomeJob( const char * fileToExecute , const Engines::FilesList& filesToExport , const Engines::FilesList& filesToImport , - /*const */CORBA::Long NumberOfProcessors , + const Engines::BatchParameters& batch_params, const Engines::MachineParameters& params) { MESSAGE("BEGIN OF SALOME_Launcher::submitSalomeJob"); @@ -135,22 +135,33 @@ CORBA::Long SALOME_Launcher::submitSalomeJob( const char * fileToExecute , try{ // find a cluster matching the structure params Engines::CompoList aCompoList ; - Engines::MachineList *aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ; + Engines::MachineList *aMachineList = _ResManager->GetFittingResources(params, aCompoList); + if (aMachineList->length() == 0) + throw SALOME_Exception("No resources have been found with your parameters"); + const Engines::MachineParameters* p = _ResManager->GetMachineParameters((*aMachineList)[0]); string clustername(p->alias); - + INFOS("Choose cluster" << clustername); + // search batch manager for that cluster in map or instanciate one std::map < string, BatchLight::BatchManager * >::const_iterator it = _batchmap.find(clustername); - SCRUTE(clustername); if(it == _batchmap.end()) - _batchmap[clustername] = FactoryBatchManager( p ); + { + _batchmap[clustername] = FactoryBatchManager(p); + // TODO: Add a test for the cluster ! + } - // submit job on cluster - BatchLight::Job* job = new BatchLight::Job( fileToExecute, filesToExport, filesToImport, NumberOfProcessors ); + // create and submit job on cluster + BatchLight::Job* job = new BatchLight::Job(fileToExecute, filesToExport, filesToImport, batch_params); + bool res = job->check(); + if (!res) { + delete job; + throw SALOME_Exception("Job parameters are bad (see informations above)"); + } jobId = _batchmap[clustername]->submitJob(job); } catch(const SALOME_Exception &ex){ - MESSAGE(ex.what()); + INFOS(ex.what()); THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR); } return jobId; diff --git a/src/Launcher/SALOME_Launcher.hxx b/src/Launcher/SALOME_Launcher.hxx index 053e6061e..fa1228697 100644 --- a/src/Launcher/SALOME_Launcher.hxx +++ b/src/Launcher/SALOME_Launcher.hxx @@ -49,14 +49,14 @@ public: ~SALOME_Launcher(); CORBA::Long submitSalomeJob(const char * fileToExecute , - const Engines::FilesList& filesToExport , - const Engines::FilesList& filesToImport , - /*const*/ CORBA::Long NumberOfProcessors , - const Engines::MachineParameters& params); + const Engines::FilesList& filesToExport , + const Engines::FilesList& filesToImport , + const Engines::BatchParameters& batch_params, + const Engines::MachineParameters& params); - char* querySalomeJob( /*const */CORBA::Long jobId, const Engines::MachineParameters& params); - void deleteSalomeJob( /*const*/ CORBA::Long jobId, const Engines::MachineParameters& params); - void getResultSalomeJob( const char * directory, /*const*/ CORBA::Long jobId, const Engines::MachineParameters& params ); + char* querySalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params); + void deleteSalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params); + void getResultSalomeJob( const char * directory, const CORBA::Long jobId, const Engines::MachineParameters& params ); void Shutdown(); diff --git a/src/LifeCycleCORBA_SWIG/Makefile.am b/src/LifeCycleCORBA_SWIG/Makefile.am index b6e9dbebb..60f4b8305 100644 --- a/src/LifeCycleCORBA_SWIG/Makefile.am +++ b/src/LifeCycleCORBA_SWIG/Makefile.am @@ -55,8 +55,8 @@ BUILT_SOURCES = swig_wrap.cpp SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../LifeCycleCORBA -I$(srcdir)/../Utils SWIG_SOURCES = libSALOME_LifeCycleCORBA.i -pkgpython_PYTHON = libSALOME_LifeCycleCORBA.py -pkgpyexec_LTLIBRARIES = _libSALOME_LifeCycleCORBA.la +salomepython_PYTHON = libSALOME_LifeCycleCORBA.py +salomepyexec_LTLIBRARIES = _libSALOME_LifeCycleCORBA.la _libSALOME_LifeCycleCORBA_la_SOURCES = $(BUILT_SOURCES) $(SWIG_SOURCES) _libSALOME_LifeCycleCORBA_la_CPPFLAGS =\ @PYTHON_INCLUDES@ \ @@ -93,4 +93,4 @@ dist_salomescript_DATA =\ TestLifeCycleCORBA.py # It's not needed to specify libSALOME_LifeCycleCORBA.py. It is -# automaticaly installed through the swig target pkgpython_PYTHON. +# automaticaly installed through the swig target salomepython_PYTHON. diff --git a/src/Logger/SALOME_Logger_Server.hxx b/src/Logger/SALOME_Logger_Server.hxx index 5b1f13f93..6481eb995 100644 --- a/src/Logger/SALOME_Logger_Server.hxx +++ b/src/Logger/SALOME_Logger_Server.hxx @@ -11,6 +11,8 @@ #if !defined SALOME_Logger_Server_include #define SALOME_Logger_Server_include +#include + #ifndef WNT #include #else diff --git a/src/ModuleCatalog/Makefile.am b/src/ModuleCatalog/Makefile.am index 83f138d3d..45dd39b49 100644 --- a/src/ModuleCatalog/Makefile.am +++ b/src/ModuleCatalog/Makefile.am @@ -103,7 +103,6 @@ SALOME_ModuleCatalog_Server_CPPFLAGS =\ SALOME_ModuleCatalog_Server_LDADD =\ libSalomeCatalog.la \ - $(COMMON_LIBS) \ @CORBA_LIBS@ # SALOME_ModuleCatalog_Client @@ -113,5 +112,4 @@ SALOME_ModuleCatalog_Client_CPPFLAGS =\ SALOME_ModuleCatalog_Client_LDADD =\ libSalomeCatalog.la \ - $(COMMON_LIBS) \ @CORBA_LIBS@ diff --git a/src/NOTIFICATION_SWIG/Makefile.am b/src/NOTIFICATION_SWIG/Makefile.am index 42f570e11..e043680f4 100644 --- a/src/NOTIFICATION_SWIG/Makefile.am +++ b/src/NOTIFICATION_SWIG/Makefile.am @@ -40,8 +40,8 @@ BUILT_SOURCES = swig_wrap.cpp SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../Notification SWIG_SOURCES = NOTIFICATION.i -pkgpython_PYTHON = libNOTIFICATION.py -pkgpyexec_LTLIBRARIES = _libNOTIFICATION.la +salomepython_PYTHON = libNOTIFICATION.py +salomepyexec_LTLIBRARIES = _libNOTIFICATION.la _libNOTIFICATION_la_SOURCES = $(BUILT_SOURCES) $(SWIG_SOURCES) \ NOTIFICATION_Swig.cxx NOTIFICATION_Swig.hxx SALOME_NOTIFICATION_SWIG.hxx _libNOTIFICATION_la_CPPFLAGS =\ @@ -49,6 +49,7 @@ _libNOTIFICATION_la_CPPFLAGS =\ -I$(srcdir)/../Notification \ -I$(srcdir)/../Basics \ -I$(srcdir)/../SALOMELocalTrace \ + -I$(top_builddir)/salome_adm/unix \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ diff --git a/src/NamingService/NamingService_WaitForServerReadiness.cxx b/src/NamingService/NamingService_WaitForServerReadiness.cxx index 3021b6c85..d4eb2aa7e 100644 --- a/src/NamingService/NamingService_WaitForServerReadiness.cxx +++ b/src/NamingService/NamingService_WaitForServerReadiness.cxx @@ -66,9 +66,8 @@ void NamingService_WaitForServerReadiness(SALOME_NamingService* NS, { if (serverName.length() == 0) { - char* dummyadr = NS->getIORaddr(); // to wait for naming service + CORBA::String_var dummyadr = NS->getIORaddr(); // to wait for naming service found = 1; - delete [] dummyadr; break; // naming service found } else @@ -81,9 +80,9 @@ void NamingService_WaitForServerReadiness(SALOME_NamingService* NS, } MESSAGE("Server "<< serverName <<" not yet ready, waiting..."); #ifndef WNT - int a = nanosleep(&ts_req,&ts_rem); // wait before retry + nanosleep(&ts_req,&ts_rem); // wait before retry #else - Sleep(TIMESleep/1000000); + Sleep(TIMESleep/1000000); #endif } } @@ -91,9 +90,9 @@ void NamingService_WaitForServerReadiness(SALOME_NamingService* NS, { MESSAGE("CORBA::COMM_FAILURE: Naming Service not yet ready, waiting..."); #ifndef WNT - int a = nanosleep(&ts_req,&ts_rem); // wait before retry + nanosleep(&ts_req,&ts_rem); // wait before retry #else - Sleep(TIMESleep/1000000); + Sleep(TIMESleep/1000000); #endif } } diff --git a/src/NamingService/Test/NamingServiceTest.cxx b/src/NamingService/Test/NamingServiceTest.cxx index bfb70a8df..2a9e1fca2 100644 --- a/src/NamingService/Test/NamingServiceTest.cxx +++ b/src/NamingService/Test/NamingServiceTest.cxx @@ -182,9 +182,8 @@ NamingServiceTest::testConstructorDefault() //CPPUNIT_ASSERT_THROW(NS.getIORaddr(),CORBA::Exception); NS.init_orb(_orb); - char *root = NS.getIORaddr(); + CORBA::String_var root = NS.getIORaddr(); CORBA::Object_var obj = _orb->string_to_object(root); - delete [] root; CPPUNIT_ASSERT(!CORBA::is_nil(obj)); CosNaming::NamingContext_var rootContext = @@ -202,10 +201,9 @@ void NamingServiceTest::testConstructorOrb() { SALOME_NamingService NS(_orb); - char *root = NS.getIORaddr(); + CORBA::String_var root = NS.getIORaddr(); CORBA::Object_var obj = _orb->string_to_object(root); CPPUNIT_ASSERT(!CORBA::is_nil(obj)); - delete [] root; CosNaming::NamingContext_var rootContext = CosNaming::NamingContext::_narrow(obj); @@ -1208,9 +1206,8 @@ NamingServiceTest::testDestroyFullDirectory() void NamingServiceTest::testGetIorAddr() { - char *root = _NS.getIORaddr(); + CORBA::String_var root = _NS.getIORaddr(); CORBA::Object_var obj = _orb->string_to_object(root); - delete [] root; CPPUNIT_ASSERT(!CORBA::is_nil(obj)); } diff --git a/src/Notification/CosNotifyShorthands.h b/src/Notification/CosNotifyShorthands.h index 2cb2d3010..271a3776f 100644 --- a/src/Notification/CosNotifyShorthands.h +++ b/src/Notification/CosNotifyShorthands.h @@ -27,6 +27,8 @@ #ifndef _COS_NOTIFY_H_ #define _COS_NOTIFY_H_ +#include + #ifndef COS_USES_BOA #include #include diff --git a/src/Notification/Makefile.am b/src/Notification/Makefile.am index 74fb69e07..1259fbd1c 100644 --- a/src/Notification/Makefile.am +++ b/src/Notification/Makefile.am @@ -57,6 +57,7 @@ libSalomeNotification_la_CPPFLAGS =\ -I$(srcdir)/../Basics \ -I$(srcdir)/../SALOMELocalTrace \ -I$(srcdir)/../Utils \ + -I$(top_builddir)/salome_adm/unix \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ diff --git a/src/ParallelContainer/SALOME_ParallelContainer_i.cxx b/src/ParallelContainer/SALOME_ParallelContainer_i.cxx index 937a2274b..97f655b39 100644 --- a/src/ParallelContainer/SALOME_ParallelContainer_i.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainer_i.cxx @@ -1035,3 +1035,34 @@ Engines_Parallel_Container_i::createSalome_file(const char* origFileName) return theSalome_file; } +//============================================================================= +/*! + * CORBA attribute: Container working directory + */ +//============================================================================= + +char* +Engines_Parallel_Container_i::workingdir() +{ + char wd[256]; + getcwd (wd,256); + return CORBA::string_dup(wd) ; +} + +//============================================================================= +/*! + * CORBA attribute: Container log file name + */ +//============================================================================= + +char* +Engines_Parallel_Container_i::logfilename() +{ + return CORBA::string_dup(_logfilename.c_str()) ; +} + +void +Engines_Parallel_Container_i::logfilename(const char* name) +{ + _logfilename=name; +} diff --git a/src/ParallelContainer/SALOME_ParallelContainer_i.hxx b/src/ParallelContainer/SALOME_ParallelContainer_i.hxx index 7eaef5c7b..34d980fdb 100644 --- a/src/ParallelContainer/SALOME_ParallelContainer_i.hxx +++ b/src/ParallelContainer/SALOME_ParallelContainer_i.hxx @@ -95,6 +95,10 @@ public: virtual void ping(); char* name(); + char* workingdir(); + char* logfilename(); + void logfilename(const char* name); + virtual void Shutdown(); char* getHostName(); CORBA::Long getPID(); @@ -143,6 +147,7 @@ protected: SALOME_NamingService *_NS ; std::string _library_path; std::string _containerName; + std::string _logfilename; CORBA::ORB_var _orb; PortableServer::POA_var _poa; PortableServer::ObjectId * _id ; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index f282ac735..ea88da8f8 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -473,7 +473,7 @@ bool isPythonContainer(const char* ContainerName) * see BuildTempFileToLaunchRemoteContainer() * * Else rely on distant configuration. Command is under the form (example): - * ssh user@machine distantPath/runRemote.sh hostNS portNS \ + * ssh user@machine distantPath/runRemote.sh hostNS portNS workingdir \ * SALOME_Container containerName &" * - where user is ommited if not specified in CatalogResources, @@ -483,6 +483,7 @@ bool isPythonContainer(const char* ContainerName) * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh) * - where portNS is the port used by CORBA naming server (set by scripts to * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh) + * - where workingdir is the requested working directory for the container */ //============================================================================= @@ -514,7 +515,7 @@ SALOME_ResourcesManager::BuildCommandToLaunchRemoteContainer nbproc = params.nb_node * params.nb_proc_per_node; } - // "ssh user@machine distantPath/runRemote.sh hostNS portNS \ + // "ssh user@machine distantPath/runRemote.sh hostNS portNS workingdir \ // SALOME_Container containerName &" if (resInfo.Protocol == rsh) @@ -550,6 +551,13 @@ SALOME_ResourcesManager::BuildCommandToLaunchRemoteContainer ASSERT(getenv("NSPORT")); command += getenv("NSPORT"); // port of CORBA name server + command += " '"; + std::string wdir=params.workingdir.in(); + if(wdir == "$TEMPDIR") + wdir="\\$TEMPDIR"; + command += wdir; // requested working directory + command += "'"; + if(params.isMPI) { command += " mpirun -np "; @@ -570,13 +578,6 @@ SALOME_ResourcesManager::BuildCommandToLaunchRemoteContainer command += idc; command += " -"; AddOmninamesParams(command); - command += " > /tmp/"; - command += _NS->ContainerName(params); - command += "_"; - command += GetHostname(); - command += "_"; - command += getenv( "USER" ) ; - command += ".log 2>&1 &" ; MESSAGE("command =" << command); } @@ -629,10 +630,32 @@ SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer else { + command=""; + std::string wdir=params.workingdir.in(); + std::cerr << wdir << std::endl; + if(wdir != "") + { + // a working directory is requested + if(wdir == "$TEMPDIR") + { + // a new temporary directory is requested + char dir[]="/tmp/salomeXXXXXX"; + char* mdir=mkdtemp(dir); + if(mdir==NULL) + std::cerr << "Problem in mkdtemp " << dir << " " << mdir << std::endl; + else + command="cd "+std::string(dir)+";"; + } + else + { + // a permanent directory is requested use it or create it + command="mkdir -p " + wdir + " && cd " + wdir + ";"; + } + } if (isPythonContainer(params.container_name)) - command = "SALOME_ContainerPy.py "; + command += "SALOME_ContainerPy.py "; else - command = "SALOME_Container "; + command += "SALOME_Container "; } command += _NS->ContainerName(params); @@ -641,13 +664,7 @@ SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer command += idc; command += " -"; AddOmninamesParams(command); - command += " > /tmp/"; - command += _NS->ContainerName(params); - command += "_"; - command += GetHostname(); - command += "_"; - command += getenv( "USER" ) ; - command += ".log 2>&1 &" ; + MESSAGE("Command is ... " << command); return command; } @@ -717,13 +734,6 @@ SALOME_ResourcesManager::BuildCommand command += containerName; command += " -"; AddOmninamesParams(command); - command += " > /tmp/"; - command += containerName; - command += "_"; - command += machine; - command += "_"; - command += getenv( "USER" ) ; - command += ".log 2>&1 &" ; SCRUTE( command ); return command; @@ -823,11 +833,9 @@ void SALOME_ResourcesManager::AddOmninamesParams(string& command) const //} //command += nameservice ; - char *iorstr = _NS->getIORaddr(); + CORBA::String_var iorstr = _NS->getIORaddr(); command += "ORBInitRef NameService="; command += iorstr; - //It's in fact a CORBA::String allocated with new [] !!! - delete [] iorstr; } @@ -839,8 +847,9 @@ void SALOME_ResourcesManager::AddOmninamesParams(string& command) const void SALOME_ResourcesManager::AddOmninamesParams(ofstream& fileStream) const { + CORBA::String_var iorstr = _NS->getIORaddr(); fileStream << "ORBInitRef NameService="; - fileStream << _NS->getIORaddr(); + fileStream << iorstr; } @@ -987,14 +996,7 @@ SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer _CommandForRemAccess = command; command += " "; command += _TmpFileName; - command += " > "; - command += "/tmp/"; - command += _NS->ContainerName(params); - command += "_"; - command += machine; - command += "_"; - command += getenv( "USER" ) ; - command += ".log 2>&1 &"; + SCRUTE(command); return command; diff --git a/src/SALOMEDS/Makefile.am b/src/SALOMEDS/Makefile.am index 0d9bac30a..37686d204 100644 --- a/src/SALOMEDS/Makefile.am +++ b/src/SALOMEDS/Makefile.am @@ -71,9 +71,6 @@ COMMON_CPPFLAGS=\ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ -# This flag is used to resolve the dependencies of OCC libraries. -LDXMUFLAGS = -L/usr/X11R6/lib@LIB_LOCATION_SUFFIX@ -lXmu - # This local variable defines the list of dependant libraries common to all target in this package. COMMON_LIBS =\ ../TOOLSDS/libTOOLSDS.la \ @@ -87,8 +84,7 @@ COMMON_LIBS =\ ../GenericObj/libSalomeGenericObj.la \ ../LifeCycleCORBA/libSalomeLifeCycleCORBA.la \ $(top_builddir)/idl/libSalomeIDLKernel.la\ - @HDF5_LIBS@ \ - $(LDXMUFLAGS) + @HDF5_LIBS@ #LDFLAGS+= -lSalomeGenericObj -lSalomeLifeCycleCORBA @@ -288,8 +284,10 @@ bin_PROGRAMS = SALOMEDS_Server SALOMEDS_Client SALOMEDS_Server_SOURCES = SALOMEDS_Server.cxx SALOMEDS_Server_CPPFLAGS = $(COMMON_CPPFLAGS) -SALOMEDS_Server_LDADD = libSalomeDS.la +SALOMEDS_Server_LDADD = libSalomeDS.la \ + $(HDF5_LIBS) $(CORBA_LIBS) SALOMEDS_Client_SOURCES = SALOMEDS_Client.cxx SALOMEDS_Client_CPPFLAGS = $(COMMON_CPPFLAGS) -SALOMEDS_Client_LDADD = libSalomeDS.la +SALOMEDS_Client_LDADD = libSalomeDS.la \ + $(HDF5_LIBS) $(CORBA_LIBS) diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.hxx b/src/SALOMEDS/SALOMEDS_Driver_i.hxx index da3a87e2e..1a61bc496 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.hxx @@ -20,12 +20,13 @@ #ifndef __SALOMEDS_DRIVER_I_H__ #define __SALOMEDS_DRIVER_I_H__ +#include + #include #include "SALOMEDSImpl_Driver.hxx" #include "SALOMEDSImpl_SComponent.hxx" #include "SALOMEDSImpl_SObject.hxx" -#include #include CORBA_SERVER_HEADER(SALOMEDS) #include CORBA_SERVER_HEADER(SALOME_Component) diff --git a/src/SALOMEDS/Test/Makefile.am b/src/SALOMEDS/Test/Makefile.am index 79200aafc..7c765fa9f 100644 --- a/src/SALOMEDS/Test/Makefile.am +++ b/src/SALOMEDS/Test/Makefile.am @@ -144,4 +144,5 @@ EXTRA_DIST = \ bin_PROGRAMS = TestSALOMEDS dist_TestSALOMEDS_SOURCES = TestSALOMEDS.cxx TestSALOMEDS_CPPFLAGS = $(COMMON_CPPFLAGS) -TestSALOMEDS_LDADD = libSALOMEDSTest.la +TestSALOMEDS_LDADD = libSALOMEDSTest.la \ + $(CORBA_LIBS) diff --git a/src/SALOMEDSImpl/Makefile.am b/src/SALOMEDSImpl/Makefile.am index 88a8ae14d..de0b5f12e 100644 --- a/src/SALOMEDSImpl/Makefile.am +++ b/src/SALOMEDSImpl/Makefile.am @@ -74,6 +74,7 @@ salomeinclude_HEADERS= \ SALOMEDSImpl_Study.hxx \ SALOMEDSImpl_StudyManager.hxx \ SALOMEDSImpl_ChildNodeIterator.hxx \ + SALOMEDSImpl_Defines.hxx \ SALOMEDSImpl_IParameters.hxx \ SALOMEDSImpl_TMPFile.hxx @@ -92,15 +93,11 @@ COMMON_CPPFLAGS=\ @HDF5_INCLUDES@ \ @BOOST_CPPFLAGS@ -# This flag is used to resolve the dependencies of OCC libraries. -LDXMUFLAGS = -L/usr/X11R6/lib@LIB_LOCATION_SUFFIX@ -lXmu - # This local variable defines the list of dependant libraries common to all target in this package. COMMON_LIBS =\ ../HDFPersist/libSalomeHDFPersist.la \ ../DF/libDF.la \ - @HDF5_LIBS@ \ - $(LDXMUFLAGS) + @HDF5_LIBS@ # @@ -219,4 +216,5 @@ libSalomeDSImpl_la_LIBADD = $(COMMON_LIBS) bin_PROGRAMS = testDS testDS_SOURCES = testDS.cxx testDS_CPPFLAGS = $(COMMON_CPPFLAGS) -testDS_LDADD = libSalomeDSImpl.la $(COMMON_LIBS) +testDS_LDADD = libSalomeDSImpl.la \ + $(HDF5_LIBS) diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.cxx b/src/SALOMETraceCollector/SALOMETraceCollector.cxx index 73163eea4..b1286b915 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -24,6 +24,8 @@ // Module : KERNEL // $Header$ +#include + #include #include #include diff --git a/src/TestContainer/Makefile.am b/src/TestContainer/Makefile.am index bca922255..8101d8b2a 100644 --- a/src/TestContainer/Makefile.am +++ b/src/TestContainer/Makefile.am @@ -97,8 +97,10 @@ libSalomeTestComponentEngine_la_LIBADD = $(COMMON_LIBS) bin_PROGRAMS = TestContainer TestLogger TestContainer_SOURCES = TestContainer.cxx TestContainer_CPPFLAGS = $(COMMON_CPPFLAGS) -TestContainer_LDADD = libSalomeTestComponentEngine.la +TestContainer_LDADD = libSalomeTestComponentEngine.la \ + $(CORBA_LIBS) TestLogger_SOURCES = TestLogger.cxx TestLogger_CPPFLAGS = $(COMMON_CPPFLAGS) -TestLogger_LDADD = libSalomeTestComponentEngine.la +TestLogger_LDADD = libSalomeTestComponentEngine.la \ + $(CORBA_LIBS) diff --git a/src/Utils/Makefile.am b/src/Utils/Makefile.am index f0c0dd785..5b3c3a37a 100644 --- a/src/Utils/Makefile.am +++ b/src/Utils/Makefile.am @@ -71,7 +71,7 @@ libOpUtil_la_CPPFLAGS = \ libOpUtil_la_LIBADD = \ ../SALOMELocalTrace/libSALOMELocalTrace.la \ - $(top_builddir)/idl/libSalomeIDLKernel.la\ + $(top_builddir)/idl/libSalomeIDLKernel.la \ @CORBA_LIBS@ diff --git a/src/Utils/Test/Makefile.am b/src/Utils/Test/Makefile.am index 682b4b417..4bcdb9b64 100644 --- a/src/Utils/Test/Makefile.am +++ b/src/Utils/Test/Makefile.am @@ -84,5 +84,5 @@ libUtilsTest_la_LIBADD = $(COMMON_LIBS) bin_PROGRAMS = TestUtils TestUtils_SOURCES = TestUtils.cxx TestUtils_CPPFLAGS = $(COMMON_CPPFLAGS) -TestUtils_LDADD = libUtilsTest.la $(COMMON_LIBS) +TestUtils_LDADD = libUtilsTest.la $(CORBA_LIBS) diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx index c48e4afd9..9ae866266 100644 --- a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx @@ -29,6 +29,8 @@ # if !defined( __DESTRUCTEUR_GENERIQUE__H__ ) # define __DESTRUCTEUR_GENERIQUE__H__ +#include + #include "SALOME_Utils.hxx" #include @@ -111,9 +113,10 @@ public : virtual void operator()(void){ typedef PortableServer::ServantBase TServant; if(_PtrObjet){ - if(TServant* aServant = dynamic_cast(_PtrObjet)){ - std::cerr << "WARNING: automatic destruction for servant is no more used. It's too late in exit. Use explicit call" << std::endl; + if(dynamic_cast(_PtrObjet)){ + // std::cerr << "WARNING: automatic destruction for servant is no more used. It's too late in exit. Use explicit call" << std::endl; /* + if(TServant* aServant = dynamic_cast(_PtrObjet)){ PortableServer::POA_var aPOA = aServant->_default_POA(); PortableServer::ObjectId_var anObjectId = aPOA->servant_to_id(aServant); aPOA->deactivate_object(anObjectId.in()); diff --git a/src/Utils/Utils_ORB_INIT.cxx b/src/Utils/Utils_ORB_INIT.cxx index e2649a580..7d7370e71 100644 --- a/src/Utils/Utils_ORB_INIT.cxx +++ b/src/Utils/Utils_ORB_INIT.cxx @@ -40,7 +40,7 @@ ORB_INIT::~ORB_INIT() { if ( ! CORBA::is_nil( _orb ) ) { - std::cerr << "WARNING: orb destroy is no more called at exit. Use explicit call." << std::endl; + MESSAGE("WARNING: orb destroy is no more called at exit. Use explicit call."); //std::cerr << "appel _orb->destroy()" << std::endl; /* try { diff --git a/src/Utils/Utils_ORB_INIT.hxx b/src/Utils/Utils_ORB_INIT.hxx index 672d630c3..e4f8c97f1 100644 --- a/src/Utils/Utils_ORB_INIT.hxx +++ b/src/Utils/Utils_ORB_INIT.hxx @@ -29,6 +29,8 @@ # if ! defined( __ORB_INIT_HXX__ ) # define __ORB_INIT_HXX__ +#include + #include "SALOME_Utils.hxx" #include "omniORB4/CORBA.h"