From: abn Date: Mon, 29 Jun 2015 11:38:47 +0000 (+0200) Subject: Moved PVSERVER CORBA engine from PARAVIS to GUI. X-Git-Tag: V7_7_0a1^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fabn%2Fpvserver_service;p=modules%2Fparavis.git Moved PVSERVER CORBA engine from PARAVIS to GUI. PVSERVER is now a simple CORBA service, not inheriting from EngineComponent class. GUI can now be compiled with the PVViewer and without the PARAVIS module. PARAVIS module is now just a GUI client. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index b9a3fe69..013d5715 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,11 +99,6 @@ FIND_PACKAGE(SalomePython REQUIRED) FIND_PACKAGE(SalomeHDF5 REQUIRED) FIND_PACKAGE(SalomeSWIG REQUIRED) -IF(NOT SALOME_LIGHT_ONLY) - FIND_PACKAGE(SalomeOmniORB REQUIRED) - FIND_PACKAGE(SalomeOmniORBPy REQUIRED) -ENDIF() - IF(SALOME_BUILD_DOC) FIND_PACKAGE(SalomeDoxygen) FIND_PACKAGE(SalomeGraphviz) @@ -256,10 +251,6 @@ SALOME_ACCUMULATE_ENVIRONMENT(PV_PLUGIN_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/lib # Sources # ======== -IF(NOT SALOME_LIGHT_ONLY) - ADD_SUBDIRECTORY(idl) # Order matters when using the wrapping - to be added AFTER src -ENDIF() - ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(adm_local) ADD_SUBDIRECTORY(resources) @@ -286,7 +277,7 @@ INCLUDE(CMakePackageConfigHelpers) # List of targets in this project we want to make visible to the rest of the world. # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup" IF(NOT SALOME_LIGHT_ONLY) - SET(_${PROJECT_NAME}_exposed_targets SalomeIDLPVServer PARAVIS) + SET(_${PROJECT_NAME}_exposed_targets PARAVIS) # Add all targets to the build-tree export set EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets} diff --git a/idl/.gitignore b/idl/.gitignore deleted file mode 100644 index 24d9077f..00000000 --- a/idl/.gitignore +++ /dev/null @@ -1 +0,0 @@ -pythonIDL.pyc diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt deleted file mode 100644 index 4e31c6b0..00000000 --- a/idl/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2010-2015 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -INCLUDE(UseOmniORB) # Provided by KERNEL - -INCLUDE_DIRECTORIES( - ${OMNIORB_INCLUDE_DIR} - ${PROJECT_BINARY_DIR}/idl -) - -ADD_DEFINITIONS(${OMNIORB_DEFINITIONS}) - -SET(SalomeIDLPARAVIS_IDLSOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/PVSERVER_Gen.idl - ) -SET(_idl_include_dirs - ${CMAKE_CURRENT_SOURCE_DIR} - ${KERNEL_ROOT_DIR}/idl/salome - ) -SET(_idl_link_flags - ${KERNEL_SalomeIDLKernel} -) - -# Demand Python generation: -SET(OMNIORB_PYTHON_BACKEND 1) -OMNIORB_ADD_MODULE(SalomeIDLPVServer "${SalomeIDLPARAVIS_IDLSOURCES}" "${_idl_include_dirs}" "${_idl_link_flags}") -INSTALL(TARGETS SalomeIDLPVServer EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/idl/PVSERVER_Gen.idl b/idl/PVSERVER_Gen.idl deleted file mode 100644 index fffe78bc..00000000 --- a/idl/PVSERVER_Gen.idl +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2010-2015 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Adrien Bruneton (CEA) - - -#ifndef __PVSERVER_GEN__ -#define __PVSERVER_GEN__ - -#include "SALOME_Exception.idl" -#include "SALOME_Component.idl" -#include "SALOMEDS.idl" -#include "SALOME_Exception.idl" - -/*! - The main package of interfaces of the module %PARAVIS. - The main service provided by the interface is to give to the caller the URL of the pvserver, and to launch it - if it is not already started. - The connection to the ParaView's pvserver should then be done using ParaView's API directly. -*/ -module PVSERVER_ORB { - - /*! - * \brief The main interface class for PARAVIS server. - * Instantiation of this class has to be done before access to any other PARAVIS interfaces - */ - interface PVSERVER_Gen : Engines::EngineComponent, SALOMEDS::Driver - { - - /*! - * \brief Returns IOR of the current object. - */ - string GetIOR(); - - /*! If a pvserver is already started, returns its current URL, regardless of the provided - * parameters. - * If not, start a pvserver on the machine hosting the PARAVIS engine and on the given port. - * If port <= 0, a free port is automatically detected, starting from the usual 11111 pvserver port. - */ - string FindOrStartPVServer(in long port); - - /*! Tries to stop the PVserver currently running (send KILL). - * @return false if no server was running, true otherwise. - */ - boolean StopPVServer(); - - /*! Indicates if the GUI process is already connected to the pvserver. - * This avoids multiple attempts to connect from a single thread (makes ParaView crash). */ - void SetGUIConnected(in boolean isConnected); - - /*! Indicates if the GUI process is already connected to the pvserver. - * This avoids multiple attempts to connect from a single thread (makes ParaView crash). */ - boolean GetGUIConnected(); - - }; - -}; - -#endif \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee27c9a2..0fbd320f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,7 +24,6 @@ SET(_subdirs IF(NOT SALOME_LIGHT_ONLY) LIST(APPEND _subdirs - ENGINE PVGUI ) ENDIF(NOT SALOME_LIGHT_ONLY) diff --git a/src/ENGINE/CMakeLists.txt b/src/ENGINE/CMakeLists.txt deleted file mode 100644 index d8914e2b..00000000 --- a/src/ENGINE/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2010-2015 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# 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 -# - -SET(_bin_SCRIPTS - PVSERVER.py - PVSERVER_utils.py - ) -# --- rules --- -SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_SCRIPT_PYTHON}) - - \ No newline at end of file diff --git a/src/ENGINE/PVSERVER.py b/src/ENGINE/PVSERVER.py deleted file mode 100644 index 46ca5ab1..00000000 --- a/src/ENGINE/PVSERVER.py +++ /dev/null @@ -1,178 +0,0 @@ -# Copyright (C) 2007-2015 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# Author : Adrien Bruneton (CEA) -# - -import PVSERVER_ORB__POA -import SALOME_ComponentPy -import SALOMEDS -import SALOME -import PVSERVER_utils -import subprocess as subp -import socket -from time import sleep -import os -#from SALOME_utilities import MESSAGE - -def MESSAGE(m): - """ Debug function """ - pass - #os.system("echo \"%s\" >> /tmp/paravis_log.txt" % m) - -class PVSERVER_Impl: - """ The core implementation (non CORBA, or Study related). - See the IDL for the documentation. - """ - MAX_PVSERVER_PORT_TRIES = 1000 # Maximum number of tries to get a free port for the PVServer - PVSERVER_DEFAULT_PORT = 11111 # First port being tried to launch the pvserver - - def __init__(self): - self.pvserverPort = -1 - self.pvserverPop = None # Popen object from subprocess module - self.isGUIConnected = False # whether there is an active connection from the GUI. - try: - import paraview - tmp=paraview.__file__ - except: - raise Exception("PVSERVER_Impl.__init__ : \"import paraview\" failed !") - # deduce dynamically PARAVIEW_ROOT_DIR from the paraview module location - self.PARAVIEW_ROOT_DIR = None - ZE_KEY_TO_FIND_PV_ROOT_DIR="lib" - li=tmp.split(os.path.sep) ; li.reverse() - if ZE_KEY_TO_FIND_PV_ROOT_DIR not in li: - raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR, - "PVSERVER_Impl.__init__ : error during dynamic deduction of PARAVIEW_ROOT_DIR : Loc of paraview module is \"%s\" ! \"%s\" is supposed to be the key to deduce it !"%(tmp,ZE_KEY_TO_FIND_PV_ROOT_DIR), - "PVSERVER.py", 0)) - li=li[li.index("lib")+1:] ; li.reverse() - self.PARAVIEW_ROOT_DIR = os.path.sep.join(li) - - """ - Private. Identify a free port to launch the PVServer. - This is done by trying to bind a socket on the port. - We are still subject to a race condition between this detection mechanism and the actual launch of the pvserver - itself ... - """ - def __getFreePort(self, startPort): - cnt = 0 - currPort = startPort - while cnt < self.MAX_PVSERVER_PORT_TRIES: - try: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.bind(('', currPort)) - s.close() - return currPort - except socket.error as e: - cnt += 1 - currPort += 1 - pass - raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR, - "[PVSERVER] maximum number of tries to retrieve a free port for the PVServer", - "PVSERVER.py", 0)) - - def FindOrStartPVServer( self, port ): - MESSAGE("[PVSERVER] FindOrStartPVServer ...") - host = "localhost" - alive = True - if self.pvserverPop is None: - alive = False - else: - # Poll active server to check if still alive - self.pvserverPop.poll() - if not self.pvserverPop.returncode is None: # server terminated - alive = False - - if alive: - return "cs://%s:%d" % (host, self.pvserverPort) - - # (else) Server not alive, start it: - pvServerPath = os.path.join(self.PARAVIEW_ROOT_DIR, 'bin', 'pvserver') - opt = [] - if port <= 0: - port = self.__getFreePort(self.PVSERVER_DEFAULT_PORT) - self.pvserverPop = subp.Popen([pvServerPath, "--multi-clients", "--server-port=%d" % port, "--use-offscreen-rendering"]) - sleep(3) # Give some time to the server to start up to avoid - # ugly messages on the client side saying that it cannot connect - # Is PID still alive? If yes, consider that the launch was successful - self.pvserverPop.poll() - if self.pvserverPop.returncode is None: - success = True - self.pvserverPort = port - MESSAGE("[PVSERVER] pvserver successfully launched on port %d" % port) - else: - raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR, - "[PVSERVER] Unable to start PVServer on port %d!" % port, - "PVSERVER.py", 0)) - return "cs://%s:%d" % (host, self.pvserverPort) - - def StopPVServer( self ): - MESSAGE("[PVSERVER] Trying to stop PVServer (sending KILL) ...") - if not self.pvserverPop is None: - self.pvserverPop.poll() - if self.pvserverPop.returncode is None: - # Terminate if still running: - self.pvserverPop.terminate() - MESSAGE("[PVSERVER] KILL signal sent.") - return True - MESSAGE("[PVSERVER] Nothing to kill.") - return False - - def SetGUIConnected( self, isConnected ): - self.isGUIConnected = isConnected - - def GetGUIConnected( self ): - return self.isGUIConnected - -class PVSERVER(PVSERVER_ORB__POA.PVSERVER_Gen, - SALOME_ComponentPy.SALOME_ComponentPy_i, - PVSERVER_Impl): - """ - Construct an instance of PVSERVER module engine. - The class PVSERVER implements CORBA interface PVSERVER_Gen (see PVSERVER_Gen.idl). - It is inherited from the classes SALOME_ComponentPy_i (implementation of - Engines::EngineComponent CORBA interface - SALOME component). - """ - def __init__ ( self, orb, poa, contID, containerName, instanceName, - interfaceName ): - SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa, - contID, containerName, instanceName, interfaceName, 0) - PVSERVER_Impl.__init__(self) - # - self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb ) - # - - """ Override base class destroy to make sure we try to kill the pvserver - before leaving. - """ - def destroy(self): - self.StopPVServer() - # Invokes super(): - SALOME_ComponentPy.destroy(self) - - """ - Get version information. - """ - def getVersion( self ): - import salome_version - return salome_version.getVersion("PARAVIS", True) - - """ - Get engine IOR - """ - def GetIOR(self): - return PVSERVER_utils.getEngineIOR() diff --git a/src/ENGINE/PVSERVER_utils.py b/src/ENGINE/PVSERVER_utils.py deleted file mode 100644 index 85f20323..00000000 --- a/src/ENGINE/PVSERVER_utils.py +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright (C) 2007-2015 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# 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 : PVSERVER_utils.py -# Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -# --- -# -__all__ = [ - "moduleName", - "verbose", - "getORB", - "getNS", - "getLCC", - "getStudyManager", - "getEngine", - "getEngineIOR", - ] - -from omniORB import CORBA -from SALOME_NamingServicePy import SALOME_NamingServicePy_i -from LifeCycleCORBA import LifeCycleCORBA -import SALOMEDS -import SALOMEDS_Attributes_idl -import PVSERVER_ORB -import os - -### -# Get PVSERVER module's name -### -def moduleName(): - return "PVSERVER" - -### -# Get verbose level -### -__verbose__ = None -def verbose(): - global __verbose__ - if __verbose__ is None: - try: - __verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) ) - except: - __verbose__ = 0 - pass - pass - return __verbose__ - -### -# Get ORB reference -### -__orb__ = None -def getORB(): - global __orb__ - if __orb__ is None: - __orb__ = CORBA.ORB_init( [''], CORBA.ORB_ID ) - pass - return __orb__ - -### -# Get naming service instance -### -__naming_service__ = None -def getNS(): - global __naming_service__ - if __naming_service__ is None: - __naming_service__ = SALOME_NamingServicePy_i( getORB() ) - pass - return __naming_service__ - -## -# Get life cycle CORBA instance -## -__lcc__ = None -def getLCC(): - global __lcc__ - if __lcc__ is None: - __lcc__ = LifeCycleCORBA( getORB() ) - pass - return __lcc__ - -## -# Get study manager -### -__study_manager__ = None -def getStudyManager(): - global __study_manager__ - if __study_manager__ is None: - obj = getNS().Resolve( '/myStudyManager' ) - __study_manager__ = obj._narrow( SALOMEDS.StudyManager ) - pass - return __study_manager__ - -### -# Get PVSERVER engine -### -__engine__ = None -def getEngine(): - global __engine__ - if __engine__ is None: - __engine__ = getLCC().FindOrLoadComponent( "FactoryServer", moduleName() ) - pass - return __engine__ - -### -# Get PVSERVER engine IOR -### -def getEngineIOR(): - IOR = "" - if getORB() and getEngine(): - IOR = getORB().object_to_string( getEngine() ) - pass - return IOR diff --git a/src/PVGUI/CMakeLists.txt b/src/PVGUI/CMakeLists.txt index 12873643..40962d0d 100644 --- a/src/PVGUI/CMakeLists.txt +++ b/src/PVGUI/CMakeLists.txt @@ -21,10 +21,9 @@ INCLUDE(UseQt4Ext) # --- options --- -INCLUDE_DIRECTORIES(${OMNIORB_INCLUDE_DIR} +INCLUDE_DIRECTORIES( ${KERNEL_INCLUDE_DIRS} - ${GUI_INCLUDE_DIRS} - ${PROJECT_BINARY_DIR}/idl + ${GUI_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} ${CAS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} @@ -35,7 +34,6 @@ INCLUDE_DIRECTORIES(${OMNIORB_INCLUDE_DIR} # additional preprocessor / compiler flags ADD_DEFINITIONS(${CAS_DEFINITIONS}) -ADD_DEFINITIONS(${OMNIORB_DEFINITIONS}) ADD_DEFINITIONS(${KERNEL_DEFINITIONS}) # libraries to link to @@ -44,7 +42,6 @@ SET(_PARAVIEW_APP_COMPO_LIB ) SET(_link_LIBRARIES - ${OMNIORB_LIBRARIES} ${QT_LIBRARIES} ${PYTHON_LIBS} ${KERNEL_LDFLAGS} diff --git a/src/PVGUI/PVGUI_Module.cxx b/src/PVGUI/PVGUI_Module.cxx index 42cad016..247f4b69 100644 --- a/src/PVGUI/PVGUI_Module.cxx +++ b/src/PVGUI/PVGUI_Module.cxx @@ -36,7 +36,7 @@ #include "PVViewer_ViewModel.h" #include "PVGUI_ParaViewSettingsPane.h" #include "PVViewer_GUIElements.h" -#include "PVViewer_EngineWrapper.h" +#include "PVServer_ServiceWrapper.h" #include "PVGUI_DataModel.h" // SALOME Includes @@ -208,9 +208,9 @@ PVGUI_Module::~PVGUI_Module() by the PVViewer code in GUI (class PVViewer_EngineWrapper). \sa GetCPPEngine() */ -PVViewer_EngineWrapper* PVGUI_Module::GetEngine() +PVServer_ServiceWrapper* PVGUI_Module::GetEngine() { - return PVViewer_EngineWrapper::GetInstance(); + return PVServer_ServiceWrapper::GetInstance(); } /*! diff --git a/src/PVGUI/PVGUI_Module.h b/src/PVGUI/PVGUI_Module.h index fec72619..3cac7f89 100644 --- a/src/PVGUI/PVGUI_Module.h +++ b/src/PVGUI/PVGUI_Module.h @@ -35,7 +35,7 @@ class pqServer; class pqPythonScriptEditor; class pqPVApplicationCore; class PVViewer_GUIElements; -class PVViewer_EngineWrapper; +class PVServer_ServiceWrapper; class SUIT_ViewWindow; class PVGUI_Module: public LightApp_Module @@ -135,7 +135,7 @@ public: virtual void createPreferences(); - inline static PVViewer_EngineWrapper* GetEngine(); + inline static PVServer_ServiceWrapper* GetEngine(); inline static pqPVApplicationCore* GetPVApplication(); // not used inside PARAVIS virtual CAM_DataModel* createDataModel(); diff --git a/src/PV_SWIG/pvserver.py b/src/PV_SWIG/pvserver.py index c00c1ee2..ee6d0609 100644 --- a/src/PV_SWIG/pvserver.py +++ b/src/PV_SWIG/pvserver.py @@ -29,6 +29,6 @@ it available in the global variables myParavis and myPVServerService import PVSERVER_utils ## Initialize PARAVIS interface -myPVServerService = PVSERVER_utils.getEngine() +myPVServerService = PVSERVER_utils.getService() # Backward compatibility: myParavis = myPVServerService diff --git a/test/standalone/src/PVViewer_Core.h b/test/standalone/src/PVViewer_Core.h index 947ef16f..b8e96c85 100644 --- a/test/standalone/src/PVViewer_Core.h +++ b/test/standalone/src/PVViewer_Core.h @@ -23,7 +23,7 @@ #include -class PVViewer_EngineWrapper; +class PVServer_ServiceWrapper; class PVViewer_Behaviors; class LogWindow; class QMainWindow;