if verbose(): print process_id
for pid, cmd in process_id.items():
#print "see process %s : %s"% (pid, cmd[0])
- if pid == command_pid:
- already_in=1
+ if pid == command_pid:
+ already_in=1
pass
pass
pass
command=(command.split(" "))[0]
if already_in == 0:
try:
- process_ids.append({command_pid: [command]})
- fpid=open(filedict,'w')
+ process_ids.append({command_pid: [command]})
+ fpid=open(filedict,'w')
pickle.dump(process_ids, fpid)
- fpid.close()
+ fpid.close()
except:
- print "addToKillList: can not add command %s to the kill list"% filedict
- pass
- pass
+ print "addToKillList: can not add command %s to the kill list"% filedict
+ pass
+ pass
pass
def killList():
if pidfield != "egrep" :
if sys.platform == "win32":
import win32pm
- print 'stop process '+pidfield+' : omniNames'
+ print 'stop process '+pidfield+' : omniNames'
win32pm.killpid(int(pidfield),0)
else:
- if verbose(): print 'stop process '+pidfield+' : omniNames'
+ if verbose(): print 'stop process '+pidfield+' : omniNames'
os.system('kill -9 '+pidfield)
pidfield = field
except:
while pid != "" and len(a.split(" ")) < 2:
a = commands.getoutput("pid=`ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"`; kill -9 $pid")
pid = commands.getoutput("ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"")
- print pid
+ print pid
pass
os.environ["BaseDir"]=os.environ["HOME"]
else:
os.environ["BaseDir"]="/tmp"
-
- try:
- os.mkdir(os.environ["BaseDir"] + "/logs")
+
+ try:
+ os.mkdir(os.environ["BaseDir"] + "/logs")
os.chmod(os.environ["BaseDir"] + "/logs", 0777)
- except:
- #print "Can't create " + os.environ["BaseDir"] + "/logs"
- pass
-
- upath = os.environ["BaseDir"] + "/logs/";
- if sys.platform == "win32":
- upath += os.environ["Username"];
- else:
- upath += os.environ["USER"];
-
- try:
- os.mkdir(upath)
- except:
- #print "Can't create " + upath
- pass
-
- #os.system("touch " + upath + "/dummy")
- for fname in os.listdir(upath):
- try:
- os.remove(upath + "/" + fname)
- except:
- pass
- #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
-
- print "Name Service... "
- #hname=os.environ["HOST"] #commands.getoutput("hostname")
+ except:
+ #print "Can't create " + os.environ["BaseDir"] + "/logs"
+ pass
+
+ upath = os.environ["BaseDir"] + "/logs/";
if sys.platform == "win32":
- hname=getShortHostName();
+ upath += os.environ["Username"];
else:
- hname = socket.gethostname();
-
- print "hname=",hname
-
- f=open(os.environ["OMNIORB_CONFIG"])
- ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
- print "ss = ", ss
- f.close()
+ upath += os.environ["USER"];
+
+ try:
+ os.mkdir(upath)
+ except:
+ #print "Can't create " + upath
+ pass
+
+ #os.system("touch " + upath + "/dummy")
+ for fname in os.listdir(upath):
+ try:
+ os.remove(upath + "/" + fname)
+ except:
+ pass
+ #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
+
+ print "Name Service... ",
+ #hname=os.environ["HOST"] #commands.getoutput("hostname")
+ if sys.platform == "win32":
+ hname=getShortHostName();
+ else:
+ hname = socket.gethostname();
+ #print "hname=",hname
+
+ f=open(os.environ["OMNIORB_CONFIG"])
+ ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
+ print "ss = ", ss,
+ f.close()
sl=ss[0]
ll = sl.split(':')
aPort = ll[-1]
#aPort=(ss.join().split(':'))[2];
- #aPort=re.findall("\d+", ss[0])[0]
-
- #aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
- #print "sed command = ", aSedCommand
- #aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
- print "port=", aPort
- if sys.platform == "win32":
- #print "start omniNames -start " + aPort + " -logdir " + upath
+ #aPort=re.findall("\d+", ss[0])[0]
+
+ #aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
+ #print "sed command = ", aSedCommand
+ #aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
+ #print "port=", aPort
+ if sys.platform == "win32":
+ #print "start omniNames -start " + aPort + " -logdir " + upath
self.CMD=['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"']
- #os.system("start omniNames -start " + aPort + " -logdir " + upath)
- else:
+ #os.system("start omniNames -start " + aPort + " -logdir " + upath)
+ else:
#self.CMD=['omniNames -start ' , aPort , ' -logdir ' , upath , ' &']
self.CMD=['omniNames','-start' , aPort, '-logdir' , upath ]
- #os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
+ #os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
- print "ok"
- print "to list contexts and objects bound int the context with the specified name : showNS "
+ print "... ok"
+ print "to list contexts and objects bound into the context with the specified name : showNS "
def initArgs(self):
self.CMD=['xterm', '-e']+ env_ld_library_path + ['python']
self.initNSArgs()
-
# In LifeCycleCORBA, FactoryServer is started with rsh on the requested
# computer if this Container does not exist. Default is localhost.
# Others Containers are started with start_impl method of FactoryServer Container.
# Initialise the ORB
self.orb=CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
# Initialise the Naming Service
- print "Obtain a reference to the root naming context"
- print args
self.initNS(args)
# --------------------------------------------------------------------------
def initNS(self,args):
- print "Obtain a reference to the root naming context"
# Obtain a reference to the root naming context
obj = self.orb.resolve_initial_references("NameService")
try:
return
except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
self.rootContext = None
- print "Lancement du Naming Service",
+ print "Launch Naming Service++",
# On lance le Naming Server (doit etre dans le PATH)
NamingServer(args).run()
print "Searching %s in Naming Service " % theName,
while(1):
try:
- aPid, aStatus = os.waitpid(thePID,os.WNOHANG)
- except Exception, exc:
- raise "Impossible de trouver %s" % theName
+ os.kill(thePID,0)
+ except:
+ raise "Process %d for %s not found" % (thePID,theName)
aCount += 1
anObj = self.Resolve(theName)
if anObj:
from Utils_Identity import getShortHostName
if sys.platform == "win32":
- # temporarily using home directory for Namning Service logs
- # to be replaced with TEMP later...
- os.environ["BaseDir"]=os.environ["HOME"]
+ # temporarily using home directory for Namning Service logs
+ # to be replaced with TEMP later...
+ os.environ["BaseDir"]=os.environ["HOME"]
else:
- os.environ["BaseDir"]="/tmp"
+ os.environ["BaseDir"]="/tmp"
os.environ["Username"]=os.environ["USER"]
# clear log files
def startOmni():
- try:
- os.mkdir(os.environ["BaseDir"] + "/logs")
- os.chmod(os.environ["BaseDir"] + "/logs", 0777)
- except:
- #print "Can't create " + os.environ["BaseDir"] + "/logs"
- pass
-
- upath = os.environ["BaseDir"] + "/logs/" + os.environ["Username"]
-
- try:
- os.mkdir(upath)
- except:
- #print "Can't create " + upath
- pass
-
- #os.system("touch " + upath + "/dummy")
- for fname in os.listdir(upath):
- try:
- os.remove(upath + "/" + fname)
- except:
- pass
- #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
-
- print "Name Service... "
- #hname=os.environ["HOST"] #commands.getoutput("hostname")
- if sys.platform == "win32":
+ try:
+ os.mkdir(os.environ["BaseDir"] + "/logs")
+ os.chmod(os.environ["BaseDir"] + "/logs", 0777)
+ except:
+ #print "Can't create " + os.environ["BaseDir"] + "/logs"
+ pass
+
+ upath = os.environ["BaseDir"] + "/logs/" + os.environ["Username"]
+
+ try:
+ os.mkdir(upath)
+ except:
+ #print "Can't create " + upath
+ pass
+
+ #os.system("touch " + upath + "/dummy")
+ for fname in os.listdir(upath):
+ try:
+ os.remove(upath + "/" + fname)
+ except:
+ pass
+ #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
+
+ print "Name Service... "
+ #hname=os.environ["HOST"] #commands.getoutput("hostname")
+ if sys.platform == "win32":
hname=getShortHostName()
- else:
- hname=socket.gethostname()
-
- print "hname=",hname
-
- f=open(os.environ["OMNIORB_CONFIG"])
- ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
- print "ss = ", ss
- f.close()
- aPort=re.findall("\d+", ss[0])[0]
-
- #aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
- #print "sed command = ", aSedCommand
- #aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
- global process_id
- print "port=", aPort
- if sys.platform == "win32":
+ else:
+ hname=socket.gethostname()
+
+ print "hname=",hname
+
+ f=open(os.environ["OMNIORB_CONFIG"])
+ ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
+ print "ss = ", ss
+ f.close()
+ aPort=re.findall("\d+", ss[0])[0]
+
+ #aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
+ #print "sed command = ", aSedCommand
+ #aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
+ global process_id
+ print "port=", aPort
+ if sys.platform == "win32":
#import win32pm
#command = ['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"']
#os.system("start omniNames -start " + aPort + " -logdir " + "\"" + upath + "\"" )
#print command
pid = win32pm.spawnpid( string.join(command, " "), -nc )
process_id[pid]=command
- else:
- os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
+ else:
+ os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
- print "ok"
- print "to list contexts and objects bound int the context with the specified name : showNS "
+ print "ok"
+ print "to list contexts and objects bound into the context with the specified name : showNS "
# In LifeCycleCORBA, FactoryServer is started with rsh on the requested
# computer if this Container does not exist. Default is localhost.
global process_id
command = self.CMD
print "INTERPSERVER::command = ", command
- if sys.platform == "win32":
+ if sys.platform == "win32":
import win32pm
pid = win32pm.spawnpid( string.join(command, " "),'-nc' )
- else:
+ else:
pid = os.spawnvp(os.P_NOWAIT, command[0], command)
process_id[pid]=self.CMD
self.PID = pid
def __init__(self,args):
self.args=args
self.initArgs()
- #if sys.platform == "win32":
- # self.SCMD1=[os.environ["KERNEL_ROOT_DIR"] + "/win32/" + os.environ["BIN_ENV"] + "/" + 'SALOME_ModuleCatalog_Server' + ".exe",'-common']
- #else:
+ #if sys.platform == "win32":
+ # self.SCMD1=[os.environ["KERNEL_ROOT_DIR"] + "/win32/" + os.environ["BIN_ENV"] + "/" + 'SALOME_ModuleCatalog_Server' + ".exe",'-common']
+ #else:
self.SCMD1=['SALOME_ModuleCatalog_Server','-common']
self.SCMD2=[]
home_dir=os.getenv('HOME')
def __init__(self,args):
self.args=args
self.initArgs()
- if sys.platform == "win32":
+ if sys.platform == "win32":
self.CMD=[os.environ["PYTHONBIN"], '\"'+os.environ["KERNEL_ROOT_DIR"] + '/bin/salome/SALOME_ContainerPy.py'+'\"','FactoryServerPy']
- else:
+ else:
self.CMD=['SALOME_ContainerPy.py','FactoryServerPy']
# ---
def __init__(self,args):
self.args=args
self.initArgs()
-# if sys.platform == "win32":
+ # if sys.platform == "win32":
# self.CMD=[os.environ["KERNEL_ROOT_DIR"] + "/win32/" + os.environ["BIN_ENV"] + "/" + 'SALOME_Container' + ".exe",'SuperVisionContainer']
-# else:
+# else:
self.CMD=['SALOME_Container','SuperVisionContainer']
# ---
def __init__(self,args):
self.args = args.copy()
# Bug 11512 (Problems with runSalome --xterm on Mandrake and Debian Sarge)
- self.args['xterm']=0
+ #self.args['xterm']=0
#
self.initArgs()
self.SCMD1=['SALOME_Session_Server']
-
self.SCMD2=[]
if 'registry' in self.args['embedded']:
self.SCMD1+=['--with','Registry',
limit=limit+10
while 1:
import os
- import re
- from os import getpid
+ import re
+ from os import getpid
from os import system
- if sys.platform == "win32":
- tmp_file = os.getenv('TEMP');
+ if sys.platform == "win32":
+ tmp_file = os.getenv('TEMP');
else:
tmp_file = '/tmp/'
- tmp_file += 'hostname_%s'%(getpid())
+ tmp_file += 'hostname_%s'%(getpid())
# status = os.system("netstat -ltn | grep -E :%s > /dev/null 2>&1"%(NSPORT))
- system( "netstat -a -n > %s" % tmp_file );
+ system( "netstat -a -n > %s" % tmp_file );
- f = open( tmp_file, 'r' );
- lines = f.readlines();
- f.close();
+ f = open( tmp_file, 'r' );
+ lines = f.readlines();
+ f.close();
- pattern = "tcp.*:([0-9]+).*:.*listen";
- regObj = re.compile( pattern, re.IGNORECASE );
+ pattern = "tcp.*:([0-9]+).*:.*listen";
+ regObj = re.compile( pattern, re.IGNORECASE );
status = 1;
- for item in lines:
- m = regObj.search( item )
- if m:
- try:
- p = int( m.group(1) )
- if p == NSPORT:
- status = 0;
- break;
- except:
- pass
- pass
+ for item in lines:
+ m = regObj.search( item )
+ if m:
+ try:
+ p = int( m.group(1) )
+ if p == NSPORT:
+ status = 0;
+ break;
+ except:
+ pass
+ pass
if status == 1:
print "%s - OK"%(NSPORT)
myhost = myhost[:-1]
f.close()
-# system('rm -f %s'%(tmp_file))
- os.remove( tmp_file );
+ os.remove( tmp_file );
#
home = os.environ['HOME']
if save_config:
from os import system
if sys.platform == "win32":
- import shutil
+ import shutil
shutil.copyfile( os.environ['OMNIORB_CONFIG'], "%s/.omniORB_last.cfg"%( home ) )
else:
- system('ln -s -f %s %s/.omniORB_last.cfg'%(os.environ['OMNIORB_CONFIG'], home))
+ system('ln -s -f %s %s/.omniORB_last.cfg'%(os.environ['OMNIORB_CONFIG'], home))
pass
#
break
def initArgs(self):
self.PID=None
self.CMD=[]
- self.ARGS=[]
+ self.ARGS=[]
if self.args['xterm']:
self.ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-hold']
+ os.getenv("LD_LIBRARY_PATH")]
myargs = myargs +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path
command = myargs + self.CMD
- print "command = ", command
- if sys.platform == "win32":
+ #print "command = ", command
+ if sys.platform == "win32":
import win32pm
#cmd_str = "\"" + string.join(command, " ") + "\""
#print cmd_str
#pid = win32pm.spawnpid( cmd_str )
pid = win32pm.spawnpid( string.join(command, " "), '-nc' )
#pid = win32pm.spawnpid( string.join(command, " ") )
- else:
- pid = os.spawnvp(os.P_NOWAIT, command[0], command)
+ else:
+ #pid = os.spawnvp(os.P_NOWAIT, command[0], command)
+ pid=self.daemonize(command)
process_id[pid]=self.CMD
self.PID = pid
+ return pid
+
+ def daemonize(self,args):
+ # to daemonize a process need to do the UNIX double-fork magic
+ # see Stevens, "Advanced Programming in the UNIX Environment" for details (ISBN 0201563177)
+ # and UNIX Programming FAQ 1.7 How do I get my program to act like a daemon?
+ # http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
+ #open a pipe
+ c2pread, c2pwrite = os.pipe()
+ #do first fork
+ pid=os.fork()
+ if pid > 0:
+ #first parent
+ os.close(c2pwrite)
+ #receive real pid from child
+ data=os.read(c2pread,24) #read 24 bytes
+ os.waitpid(pid,0) #remove zombie
+ os.close(c2pread)
+ # return : first parent
+ return int(data)
+
+ #first child
+ # decouple from parent environment
+ os.setsid()
+ os.close(c2pread)
+
+ # do second fork : second child not a session leader
+ try:
+ pid = os.fork()
+ if pid > 0:
+ #send real pid to parent
+ os.write(c2pwrite,"%d" % pid)
+ os.close(c2pwrite)
+ # exit from second parent
+ os._exit(0)
+ except OSError, e:
+ print >>sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror)
+ os.write(c2pwrite,"-1")
+ os.close(c2pwrite)
+ sys.exit(1)
+
+ #I am a daemon
+ os.close(0) #close stdin
+ os.open("/dev/null", os.O_RDWR) # redirect standard input (0) to /dev/null
+ try:
+ os.execvp(args[0], args)
+ except OSError, e:
+ print >>sys.stderr, "(%s) launch failed: %d (%s)" % (args[0],e.errno, e.strerror)
+ os._exit(127)
def add_path(directory, variable_name):
"""Function helper to add environment variables"""
if sys.platform == "win32":
- splitsym = ";"
+ splitsym = ";"
else:
- splitsym = ":"
+ splitsym = ":"
if not os.environ.has_key(variable_name):
os.environ[variable_name] = ""
pass
"PYTHONPATH")
- if sys.platform == "win32":
- add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir),
- "PATH")
+ if sys.platform == "win32":
+ add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir),
+ "PATH")
else:
add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir),
"LD_LIBRARY_PATH")
module_doc_tui_dir=os.path.join(module_dir,'doc','salome','tui')
module_doc_dir=os.path.join(module_dir,'doc','salome')
module_sharedoc_dir=os.path.join(module_dir,'share','doc','salome')
+ module_sharedoc_gui_dir=os.path.join(module_dir,'share','doc','salome','gui')
+ module_sharedoc_tui_dir=os.path.join(module_dir,'share','doc','salome','tui')
bin_dir=os.path.join(home_dir,'bin','salome')
lib_dir=os.path.join(home_dir,'lib','salome')
doc_tui_dir=os.path.join(home_dir,'doc','salome','tui')
doc_dir=os.path.join(home_dir,'doc','salome')
sharedoc_dir=os.path.join(home_dir,'share','doc','salome')
+ sharedoc_gui_dir=os.path.join(home_dir,'share','doc','salome','gui')
+ sharedoc_tui_dir=os.path.join(home_dir,'share','doc','salome','tui')
verbose = options.verbose
if os.path.exists(module_sharedoc_dir):
mkdir(sharedoc_dir)
for fn in os.listdir(module_sharedoc_dir):
+ if fn == 'gui':continue
+ if fn == 'tui':continue
symlink(os.path.join(module_sharedoc_dir, fn), os.path.join(sharedoc_dir, fn))
pass
pass
+ #directory share/doc/salome/gui : create it and link content
+ if os.path.exists(module_sharedoc_gui_dir):
+ mkdir(sharedoc_gui_dir)
+ for fn in os.listdir(module_sharedoc_gui_dir):
+ symlink(os.path.join(module_sharedoc_gui_dir, fn), os.path.join(sharedoc_gui_dir, fn))
+ pass
+ pass
+
+ #directory share/doc/salome/tui : create it and link content
+ if os.path.exists(module_sharedoc_tui_dir):
+ mkdir(sharedoc_tui_dir)
+ for fn in os.listdir(module_sharedoc_tui_dir):
+ symlink(os.path.join(module_sharedoc_tui_dir, fn), os.path.join(sharedoc_tui_dir, fn))
+ pass
+ pass
+
#directory share/salome/resources : create it and link content
if os.path.exists(module_share_dir):
mkdir(share_dir)
echo ---------------------------------------------
echo
# production.m4
-AC_ENABLE_DEBUG(yes)
-AC_DISABLE_PRODUCTION
+AC_ENABLE_DEBUG(no)
+AC_ENABLE_PRODUCTION(no)
echo
echo ---------------------------------------------
./src/DSC/DSC_User/Datastream/Palm/Makefile \
./src/DSC/DSC_User/Datastream/Calcium/Makefile \
./src/DSC/ParallelDSC/Makefile \
+ ./src/DSC/DSC_Python/Makefile \
./src/GenericObj/Makefile \
./src/HDFPersist/Makefile \
./src/KERNEL_PY/Makefile \
GENERATE_DEPRECATEDLIST= NO
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 25
-SHOW_USED_FILES = NO
-SHOW_DIRECTORIES = NO
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = YES
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
IMAGE_PATH = sources/
INPUT_FILTER =
FILTER_PATTERNS =
-FILTER_SOURCE_FILES = YES
+FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
-SOURCE_BROWSER = NO
-INLINE_SOURCES = NO
+SOURCE_BROWSER = YES
+INLINE_SOURCES = YES
STRIP_CODE_COMMENTS = YES
-REFERENCED_BY_RELATION = NO
+REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
HTML_FILE_EXTENSION = .html
HTML_HEADER = sources/myheader.html
HTML_FOOTER = sources/footer.html
-HTML_STYLESHEET = sources/doxygen.css
+HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
TOC_EXPAND = YES
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
-GENERATE_TREEVIEW = NO
+GENERATE_TREEVIEW = YES
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
$(DOXYGEN) ./doxyuser1; \
cd ..;
$(INSTALL) -d $(docdir)/tui/KERNEL;
- cp -fr KERNEL $(docdir)/tui
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;
This interface defines the operations needed to add a paco++ port
into a parallel DSC component.
*/
- interface Parallel_DSC : Engines::DSC {
+ interface Parallel_DSC : Engines::Superv_Component, Engines::Parallel_Component {
/*!
This operation gives the proxy node of a paco++ port to all the nodes.
void set_paco_proxy(in Object ref,
in string provides_port_name,
in Ports::PortProperties port_prop);
-
- /*!
- The SUPERV module call this method before starting the service. Thus the service
- can add is dynamics ports before is started.
-
- \param service_name service's name.
- \return true if the service is correctly initialised.
- */
- boolean init_service(in string service_name);
- };
+ };
};
#endif
<Name>set_paco_proxy</Name>
<Type>distributed</Type>
</Method>
+ </Interface>
+ <Interface>
+ <Name>Superv_Component</Name>
<Method>
<Name>init_service</Name>
<Type>distributed</Type>
salomeinclude_DATA= $(STATIDL_SOURCES:%SK.cc=%.hh)
if WITH_PACO_PARALLEL
-PAR = SALOME_ComponentPaCO.h SALOME_ComponentPaCO.cc \
+PAR = SALOME_ExceptionPaCO.h SALOME_ExceptionPaCO.cc \
+ SALOME_ComponentPaCO.h SALOME_ComponentPaCO.cc \
SALOME_PortsPaCO.h SALOME_PortsPaCO.cc \
DSC_EnginesPaCO.h DSC_EnginesPaCO.cc
PAR_LIB = libSalomeParallelIDLKernel.la
-IDL_PACO = SALOME_ComponentPaCO.idl SALOME_PortsPaCO.idl DSC_EnginesPaCO.idl
+IDL_PACO = SALOME_ExceptionPaCO.idl SALOME_ComponentPaCO.idl SALOME_PortsPaCO.idl DSC_EnginesPaCO.idl
GEN_PACO = SALOME_ComponentPaCO_Engines_Container_server.cc \
SALOME_ComponentPaCO_Engines_Container_client.cc \
SALOME_ComponentPaCO_Engines_Component_server.cc \
SALOME_ComponentPaCO_Engines_Component_client.cc \
+ SALOME_ComponentPaCO_Engines_Parallel_Component_server.cc \
+ SALOME_ComponentPaCO_Engines_Parallel_Component_client.cc \
+ SALOME_ComponentPaCO_Engines_fileTransfer_server.cc \
+ SALOME_ComponentPaCO_Engines_fileTransfer_client.cc \
+ SALOME_ComponentPaCO_Engines_Salome_file_server.cc \
+ SALOME_ComponentPaCO_Engines_Salome_file_client.cc \
+ SALOME_ComponentPaCO_Engines_Parallel_Salome_file_server.cc \
+ SALOME_ComponentPaCO_Engines_Parallel_Salome_file_client.cc \
SALOME_PortsPaCO_Ports_Port_server.cc \
SALOME_PortsPaCO_Ports_Port_client.cc \
DSC_EnginesPaCO_Engines_DSC_server.cc \
DSC_EnginesPaCO_Engines_DSC_client.cc \
+ DSC_EnginesPaCO_Engines_Superv_Component_server.cc \
+ DSC_EnginesPaCO_Engines_Superv_Component_client.cc \
DSC_EnginesPaCO_Engines_Parallel_DSC_server.cc \
DSC_EnginesPaCO_Engines_Parallel_DSC_client.cc
SALOME_ComponentPaCO_Engines_Container_client.h \
SALOME_ComponentPaCO_Engines_Component_server.h \
SALOME_ComponentPaCO_Engines_Component_client.h \
+ SALOME_ComponentPaCO_Engines_Parallel_Component_server.h \
+ SALOME_ComponentPaCO_Engines_Parallel_Component_client.h \
+ SALOME_ComponentPaCO_Engines_fileTransfer_server.h \
+ SALOME_ComponentPaCO_Engines_fileTransfer_client.h \
+ SALOME_ComponentPaCO_Engines_Salome_file_server.h \
+ SALOME_ComponentPaCO_Engines_Salome_file_client.h \
+ SALOME_ComponentPaCO_Engines_Parallel_Salome_file_server.h \
+ SALOME_ComponentPaCO_Engines_Parallel_Salome_file_client.h \
+ SALOME_ExceptionPaCO.h \
SALOME_ComponentPaCO.h \
+ SALOME_Exception.h \
SALOME_Component.h \
SALOME_PortsPaCO_Ports_Port_server.h \
SALOME_PortsPaCO_Ports_Port_client.h \
SALOME_Ports.h \
DSC_EnginesPaCO_Engines_DSC_server.h \
DSC_EnginesPaCO_Engines_DSC_client.h \
+ DSC_EnginesPaCO_Engines_Superv_Component_server.h \
+ DSC_EnginesPaCO_Engines_Superv_Component_client.h \
DSC_EnginesPaCO_Engines_Parallel_DSC_server.h \
DSC_EnginesPaCO_Engines_Parallel_DSC_client.h \
DSC_EnginesPaCO.h \
DSC_Engines.h
-XML = SALOME_Component.xml DSC_Engines.xml SALOME_Ports.xml
+XML = SALOME_Exception.xml SALOME_Component.xml DSC_Engines.xml SALOME_Ports.xml
endif
idldir = $(prefix)/idl/salome
BUILT_SOURCES = $(IDL_SOURCES) $(PAR)
+SALOME_ExceptionPaCO.h SALOME_ExceptionPaCO.cc : SALOME_Exception.idl SALOME_Exception.xml
SALOME_ComponentPaCO.h SALOME_ComponentPaCO.cc : SALOME_Component.idl SALOME_Component.xml
SALOME_PortsPaCO.h SALOME_PortsPaCO.cc : SALOME_Ports.idl SALOME_Ports.xml
DSC_EnginesPaCO.h DSC_EnginesPaCO.cc : DSC_Engines.idl DSC_Engines.xml
#ifndef _SALOME_COMPONENT_IDL_
#define _SALOME_COMPONENT_IDL_
+#include "SALOME_Exception.idl"
+
/*! \brief
This is a package of interfaces used for connecting new components to %SALOME
application. It also contains a set of interfaces used for management of %MED
interface Component ;
interface fileRef ;
interface fileTransfer ;
+ interface Salome_file;
/*! \brief Interface of the %Container.
This interface defines the process of loading and registration
*/
fileRef createFileRef(in string origFileName);
+ /*!
+ returns a Salome_file object if origFileName exists and is readable
+ else returns null object.
+
+ \param origFileName name of the file to be managed (can contain the path).
+
+ \return Salome_file CORBA reference.
+ */
+ Salome_file createSalome_file(in string origFileName);
+
/*!
returns a fileTransfer object used to copy files from the container
machine to the clients machines. Only one fileTransfer instance is
};
-
-
/*! \brief Interface of the %component.
This interface is used for interaction between the %container and the
%component and between the components inside the container.
*/
TMPFile DumpPython(in Object theStudy,
in boolean isPublished,
- out boolean isValidScript);
+ out boolean isValidScript);
+
+
+ /*!
+ Returns a CORBA Ref of a input Salome_file managed by a service.
+
+ \param service_name service's name.
+ \param file_name name of the requested file.
+
+ \return CORBA Ref of the requested file.
+
+ \exception contains informations of what if the component cannot
+ sends the file's reference.
+ */
+ Engines::Salome_file getInputFileToService(in string service_name,
+ in string Salome_file_name) raises(SALOME::SALOME_Exception);
+
+ /*!
+ This method is used before the activation of the service. It calls
+ recvFiles() on all the input Salome_file files of the service.
+
+ Before each recvFiles(), it uses the callback method named configureSalome_file.
+ This method allows the user to configure the files managed by the Salome_file.
+
+ By default, there is no files managed when a Salome_file is created,
+ but the supervisor set some files managed by the Salome_file from the information contained
+ into the schema file.
+
+ \param service_name service's name.
+
+ \exception contains informations about files that are not in a good state.
+ */
+ void checkInputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
+
+ /*!
+ This method adds a input Salome_file to a service of the component.
+
+ \param service_name service's name.
+ \param Salome_file_name name of the Salome_file
+
+ \return a reference of the Salome_file
+
+ \exception raises an exception if there is already
+ a Salome_file with this name for the service.
+ */
+ Engines::Salome_file setInputFileToService(in string service_name,
+ in string Salome_file_name) raises(SALOME::SALOME_Exception);
+
+ /*!
+ Returns a CORBA Ref of a output Salome_file managed by a service.
+
+ \param service_name service's name.
+ \param file_name name of the requested file.
+
+ \return CORBA Ref of the requested file.
+
+ \exception contains informations of what if the component cannot
+ sends the file's reference.
+ */
+ Engines::Salome_file getOutputFileToService(in string service_name,
+ in string Salome_file_name) raises(SALOME::SALOME_Exception);
+
+ /*!
+ This method is used at the end of the service. It calls
+ recvFiles() on all the output Salome_file files of the service.
+
+ Before each recvFiles(), it uses the callback method named configureSalome_file.
+ This method allows the user to configure the files managed by the Salome_file.
+
+ By default, there is no files managed when a Salome_file is created,
+ but the supervisor set some files managed by the Salome_file from the information contained
+ into the schema file.
+
+ \param service_name service's name.
+
+ \exception contains informations about files that are not in a good state.
+ */
+ void checkOutputFilesToService(in string service_name) raises(SALOME::SALOME_Exception);
+ /*!
+ This method adds an output Salome_file to a service of the component.
+
+ \param service_name service's name.
+ \param Salome_file_name name of the Salome_file
+
+ \return a reference of the Salome_file
+
+ \exception raises an exception if there is already
+ a Salome_file with this name for the service.
+ */
+ Engines::Salome_file setOutputFileToService(in string service_name,
+ in string Salome_file_name) raises(SALOME::SALOME_Exception);
} ;
+ interface Parallel_Component : Engines::Component {
+ void send_parallel_proxy_object(in Object proxy_ref);
+ };
+
/*!
A block of binary data used for file transfer. The maximum size of the
block is defined on server side.
fileBlock getBlock(in long fileId);
};
- /*! \brief Interface of fileTransfer.
+ /*!
+ This is a file managed by a Salome_file. It contains file's name, path and status.
+ The status is : "present" or "notpresent".
+ */
+ struct file {
+ string file_name;
+ string path;
+ string type;
+ string source_file_name;
+ string status;
+ long node;
+ Engines::Container container;
+ };
+
+ /*!
+ A sequence of Engines::file.
+ */
+ typedef sequence<Engines::file> files;
+
+
+ /*!
+ It is the state of a Salome_file. It contains the Salome_file's name, the name
+ of the hdf5 file where it can be saved, the number of files managed and the information
+ if all the files are received.
+ */
+ struct SfState {
+ string name;
+ string hdf5_file_name;
+ long number_of_files;
+ boolean files_ok;
+ };
+
+ /*! \brief Interface of a Salome_file managed
+ This file is independent of a Salome module. It can managed one or more
+ real files. It's useful for parallel files. Currently Salome_file cannot manage
+ two files that have the same name but not the same path.
+ */
+ interface Salome_file : Engines::fileTransfer
+ {
+ /*!
+ Load a Salome_file from a hdf5 file.
+
+ \param hdf5_file name (with path) of the hdf5_file.
+
+ \exception contains informations of errors if the loading doesn't succeed.
+ */
+ void load(in string hdf5_file) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Save a Salome_file into a hdf5_file.
+
+ \param hdf5_file name (with path) of the hdf5_file.
+
+ \exception contains informations of errors if the save doesn't succeed.
+
+ */
+ void save(in string hdf5_file) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Save a Salome_file into a hdf5_file. All files that are managed
+ are saved into the hdf5_file
+
+ \param hdf5_file name (with path) of the hdf5_file.
+
+ \exception contains informations of errors if the save doesn't succeed.
+
+ */
+ void save_all(in string hdf5_file) raises (SALOME::SALOME_Exception);
+
+/**************/
+
+ /*!
+ Add a Local file to the Salome_file.
+
+ \param file_name name of the file with the path.
+
+ \exception raised if the file is already added into the Salome_file.
+ */
+ void setLocalFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Add a Distributed file to the Salome_file.
+
+ \param comp_file_name name of the file with the path.
+
+ \exception raised if the file is already added into the Salome_file.
+ */
+ void setDistributedFile(in string comp_file_name) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Connect a Salome_file with another Salome_file.
+ It works only if the Salome_file managed only one file
+
+ \param source_Salome_file Salome_file that managed the distributed version of the file.
+
+ \exception raised if there is more or less than one file.
+ */
+ void connect(in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Connect the managed file file_name to a Salome_file.
+
+ \param file_name name of the file without the path.
+ \param source_Salome_file Salome_file that managed the distributed version of the file.
+
+ \exception raised if the file doesn't exist.
+ */
+ void connectDistributedFile(in string file_name,
+ in Engines::Salome_file source_Salome_file) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Connect the file_name with a Distributed file_name.
+
+ \param file_name name of the file without the path.
+ \param source_file_name It's the name of the file managed by the distributed source Salome_file.
+
+ \exception raised if the file doesn't exist.
+ */
+ void setDistributedSourceFile(in string file_name,
+ in string source_file_name) raises (SALOME::SALOME_Exception);
+
+/**************/
+
+ /*!
+ Get all the distributed files managed by the Salome_file and
+ check all the local files.
+
+ \exception raised if some of the files are not ok.
+ */
+ void recvFiles() raises (SALOME::SALOME_Exception) ;
+
+/**************/
+
+ /*!
+ Remove a file of the Salome_file.
+
+ \param file_name name of the file.
+
+ \exception raised if the file doesn't exist.
+ */
+ void removeFile(in string file_name) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Remove all the files of the Salome_file.
+ */
+ void removeFiles();
+
+/**************/
+
+ /*!
+ Get the list of the files managed by the Salome_file.
+ The list can be empty.
+ */
+ Engines::files getFilesInfos();
+
+ /*!
+ Get a file managed by the Salome_file.
+
+ \param file_name the name of the file.
+
+ \return CORBA file reference.
+
+ \exception raised if the file doesn't exist.
+ */
+ Engines::file getFileInfos(in string file_name) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Return the state of the Salome_file.
+ */
+ Engines::SfState getSalome_fileState();
+
+
+ /*!
+ Set the container where files are.
+
+ \param container container CORBA's reference.
+ */
+ void setContainer(in Engines::Container container);
+ };
+
+ /*! \brief Interface of fileRef.
The fileTransfer and fileRef interfaces provide a file transfer service
between different computers.
string getRef(in string machine);
};
-} ;
+ /*! \brief Interface of a Parallel_Salome_file
+ This interface is used by parallel components and containers.
+ It adds methods to enable to choose on which node of the parallel component the file has to
+ be received.
+ */
+ interface Parallel_Salome_file : Engines::Salome_file {
+
+ /*!
+ Set a number of node for the file. Default is the node 0.
+
+ \param file_name name of the file.
+ \param node_nbr node number where the file is.
+
+ \exception raised if the file doesn't exist.
+ */
+ void setFileNode(in string file_name, in long node_nbr) raises (SALOME::SALOME_Exception);
+
+ /*!
+ Get the number of the node that actually managed the file.
+
+ \param file_name name of managed file.
+
+ \return node number of the file
+
+ \exception raised if the file doesn't exist.
+ */
+ long getFileNode(in string file_name) raises (SALOME::SALOME_Exception);
+
+ /*!
+ This method update the state of file for the Parallel_Salome_file.
+
+ \param new_file the new state of file.
+ */
+ Engines::Container updateFile(in Engines::file new_file);
+
+ /*!
+ This method is used by the parallel implementation of recvFiles.
+
+ \exception raised if the file cannot be ok.
+ */
+ void recvFiles_node() raises (SALOME::SALOME_Exception);
+
+ };
+};
#endif
<Interface>
<Name>Component</Name>
<Method>
- <Name>ping</Name>
+ <Name>setInputFileToService</Name>
+ <Type>distributed</Type>
+ </Method>
+ <Method>
+ <Name>setOutputFileToService</Name>
<Type>distributed</Type>
</Method>
</Interface>
+ <Interface>
+ <Name>Parallel_Component</Name>
+ <Method>
+ <Name>send_parallel_proxy_object</Name>
+ <Type>distributed</Type>
+ </Method>
+ </Interface>
+ <Interface>
+ <Name>Salome_file</Name>
+ </Interface>
+ <Interface>
+ <Name>Parallel_Salome_file</Name>
+ </Interface>
</Module>
</GridCCM_Interface_description>
--- /dev/null
+<?xml version="1.0"?>
+<!--
+// 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 : SALOME_Exception.xml
+// Author : Andre RIBES, EDF
+-->
+<GridCCM_Interface_description
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xsi:noNamespaceSchemaLocation='$PACOPATH/IDL2Tool/interface.xsd'
+>
+
+
+</GridCCM_Interface_description>
check_lam.m4 \
check_lsf.m4 \
check_mpi.m4 \
+check_openmpi.m4 \
check_mpich.m4 \
check_omniorb.m4 \
check_opengl.m4 \
DOXYGEN_WITH_PYTHON=yes
DOXYGEN_WITH_STL=yes
;;
- [1-9].[5-9]*)
+ [[1-9]].[[5-9]]*)
DOXYGEN_WITH_PYTHON=yes
DOXYGEN_WITH_STL=yes
;;
fi
+ if test "$WITHLAM" = no; then
+dnl
+dnl ---------------------------------------------
+dnl testing OPENMPI
+dnl ---------------------------------------------
+dnl
+
+ CHECK_OPENMPI
+
+ fi
+
fi
if test x$WITHMPI2 = xyes; then
--- /dev/null
+dnl Copyright (C) 2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+dnl
+dnl See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+dnl
+dnl
+dnl
+
+AC_DEFUN([CHECK_OPENMPI],[
+AC_ARG_WITH(openmpi,
+ AC_HELP_STRING([--with-openmpi],[root directory path of openmpi installation]),
+ WITHOPENMPI="yes",WITHOPENMPI="no")
+
+MPI_INCLUDES=""
+MPI_LIBS=""
+mpi_ok=no
+
+if test "$WITHOPENMPI" = yes; then
+
+ OPENMPI_HOME=$withval
+
+ if test "$OPENMPI_HOME"; then
+ MPI_INCLUDES=`$OPENMPI_HOME/bin/mpicxx --showme:compile`
+ MPI_LIBS=`$OPENMPI_HOME/bin/mpicxx --showme:link`
+ fi
+
+ CPPFLAGS_old="$CPPFLAGS"
+ CPPFLAGS="$MPI_INCLUDES $CPPFLAGS"
+ AC_CHECK_HEADER(mpi.h,WITHOPENMPI="yes",WITHOPENMPI="no")
+ CPPFLAGS="$CPPFLAGS_old"
+
+ AC_MSG_CHECKING(for openmpi)
+ if test "$WITHOPENMPI" = "yes";then
+ mpi_ok=yes
+ AC_MSG_RESULT(yes)
+ else
+ mpi_ok=no
+ AC_MSG_RESULT(no)
+ fi
+fi
+])dnl
+
dnl author Patrick GOLDBRONN
dnl
-# AC_ENABLE_PRODUCTION
-AC_DEFUN([AC_ENABLE_PRODUCTION], [dnl
-define([AC_ENABLE_PRODUCTION_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE(production,
-changequote(<<, >>)dnl
-<< --enable-production[=PKGS] build without debug information [default=>>AC_ENABLE_PRODUCTION_DEFAULT],
-changequote([, ])dnl
-[p=${PACKAGE-default}
-case "$enableval" in
-yes) enable_production=yes ;;
-no) enable_production=no ;;
-*)
- enable_production=no
- # Look at the argument we got. We use all the common list separators.
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
- for pkg in $enableval; do
- if test "X$pkg" = "X$p"; then
- enable_production=yes
- fi
- done
- IFS="$ac_save_ifs"
- ;;
-esac],
-enable_production=AC_ENABLE_PRODUCTION_DEFAULT)dnl
+dnl AC_ENABLE_PRODUCTION
+dnl
+dnl This macro enables production build : optimized + no debugging information (-g)
+dnl default = not enabled
+dnl
+AC_DEFUN([AC_ENABLE_PRODUCTION],
+[define([AC_ENABLE_PRODUCTION_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([production],
+ [AC_HELP_STRING([--enable-production],
+ [compile in optimized mode @<:@default=]AC_ENABLE_PRODUCTION_DEFAULT[@:>@])],
+ [
+ enable_production=$enableval
+ ],
+ [enable_production=]AC_ENABLE_PRODUCTION_DEFAULT)
AC_CXX_OPTION(-Wno-deprecated,CXXFLAGS)
AC_CXX_OPTION(-Wparentheses,CXXFLAGS)
CFLAGS="$CFLAGS -O"
AC_CXX_OPTION(-Wuninitialized,CXXFLAGS)
CXXFLAGS="$CXXFLAGS -O "
+else
+ CFLAGS="$CFLAGS -O -g"
+ CXXFLAGS="$CXXFLAGS -O -g"
fi
])
# AC_DISABLE_PRODUCTION - set the default flag to --disable-production
AC_DEFUN([AC_DISABLE_PRODUCTION], [AC_ENABLE_PRODUCTION(no)])
-# AC_ENABLE_DEBUG
-AC_DEFUN([AC_ENABLE_DEBUG], [dnl
-define([AC_ENABLE_DEBUG_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE(debug,
-changequote(<<, >>)dnl
-<< --enable-debug[=PKGS] build without debug information [default=>>AC_ENABLE_DEBUG_DEFAULT],
-changequote([, ])dnl
-[p=${PACKAGE-default}
-case "$enableval" in
-yes) enable_debug=yes ;;
-no) enable_debug=no ;;
-*)
- enable_debug=no
- # Look at the argument we got. We use all the common list separators.
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
- for pkg in $enableval; do
- if test "X$pkg" = "X$p"; then
- enable_debug=yes
- fi
- done
- IFS="$ac_save_ifs"
- ;;
-esac],
-enable_debug=AC_ENABLE_DEBUG_DEFAULT)dnl
+dnl AC_ENABLE_DEBUG
+dnl
+dnl This macro enables debugging build : debug + trace
+dnl default = not enabled
+dnl
+AC_DEFUN([AC_ENABLE_DEBUG],
+ [define([AC_ENABLE_DEBUG_DEFAULT], ifelse($1, no, no, yes))dnl
+ AC_ARG_ENABLE([debug],
+ [AC_HELP_STRING([--enable-debug],
+ [build with debug and trace information @<:@default=]AC_ENABLE_DEBUG_DEFAULT[@:>@])],
+ [
+ enable_debug=$enableval
+ ],
+ [enable_debug=]AC_ENABLE_DEBUG_DEFAULT)
if test "X$enable_debug" = "Xyes"; then
CFLAGS="$CFLAGS -g -D_DEBUG_ "
(*it).second >>= value;
// ---todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC.
#if defined __GNUC__
- int ret = setenv(cle.c_str(), value, overwrite);
+// int ret = setenv(cle.c_str(), value, overwrite);
+ setenv(cle.c_str(), value, overwrite);
#else
//CCRT porting : setenv not defined in stdlib.h
std::string s(cle);
s+=value;
// char* cast because 1st arg of linux putenv function
// is not a const char* !
- int ret=putenv((char *)s.c_str());
+// int ret=putenv((char *)s.c_str());
+ putenv((char *)s.c_str());
//End of CCRT porting
#endif
MESSAGE("--- setenv: "<<cle<<" = "<< value);
CORBA::Boolean isPublished,
CORBA::Boolean& isValidScript)
{
- char* aScript = "def RebuildData(theStudy): pass";
+ const char* aScript = "def RebuildData(theStudy): pass";
char* aBuffer = new char[strlen(aScript)+1];
strcpy(aBuffer, aScript);
CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
isValidScript = true;
return aStreamFile._retn();
}
+
+Engines::Salome_file_ptr
+Engines_Component_i::getInputFileToService(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we throw an exception.
+ _Service_file_map_it = _Input_Service_file_map.find(service_name);
+ if (_Service_file_map_it == _Input_Service_file_map.end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have salome files";
+ throw SALOME::SALOME_Exception(es);
+ }
+ _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
+
+ // Try to find the Salome_file ...
+ _Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Salome_file_map_it == _map->end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have this Salome_file";
+ throw SALOME::SALOME_Exception(es);
+ }
+ Salome_file_i * Sfile = (*_map)[Salome_file_name];
+
+ return Sfile->_this();
+}
+
+Engines::Salome_file_ptr
+Engines_Component_i::setInputFileToService(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we add it.
+ _Service_file_map_it = _Input_Service_file_map.find(service_name);
+ if (_Service_file_map_it == _Input_Service_file_map.end()) {
+ _t_Salome_file_map * _map = new _t_Salome_file_map();
+ _Input_Service_file_map[service_name] = _map;
+ }
+ _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
+
+ // Try to find the Salome_file ...
+ _Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Salome_file_map_it == _map->end()) {
+ Salome_file_i * Sfile = new Salome_file_i();
+ Engines::Container_ptr container = this->GetContainerRef();
+ Sfile->setContainer(Engines::Container::_duplicate(container));
+ (*_map)[Salome_file_name] = Sfile;
+ }
+
+ Salome_file_i * Sfile = (*_map)[Salome_file_name];
+ return Sfile->_this();
+}
+
+void
+Engines_Component_i::checkInputFilesToService(const char* service_name)
+{
+ // Try to find the service, if it doesn't exist, nothing to do.
+ _Service_file_map_it = _Input_Service_file_map.find(service_name);
+ if (_Service_file_map_it != _Input_Service_file_map.end()) {
+ _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
+ _t_Salome_file_map::iterator begin = _map->begin();
+ _t_Salome_file_map::iterator end = _map->end();
+
+ for(;begin!=end;begin++) {
+ Salome_file_i * file = begin->second;
+ std::string file_port_name = begin->first;
+ configureSalome_file(service_name, file_port_name, file);
+ file->recvFiles();
+ }
+ }
+}
+
+Engines::Salome_file_ptr
+Engines_Component_i::getOutputFileToService(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we throw an exception.
+ _Service_file_map_it = _Output_Service_file_map.find(service_name);
+ if (_Service_file_map_it == _Output_Service_file_map.end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have salome files";
+ throw SALOME::SALOME_Exception(es);
+ }
+ _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+
+ // Try to find the Salome_file ...
+ _Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Salome_file_map_it == _map->end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have this Salome_file";
+ throw SALOME::SALOME_Exception(es);
+ }
+ Salome_file_i * Sfile = (*_map)[Salome_file_name];
+
+ return Sfile->_this();
+}
+
+Engines::Salome_file_ptr
+Engines_Component_i::setOutputFileToService(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we add it.
+ _Service_file_map_it = _Output_Service_file_map.find(service_name);
+ if (_Service_file_map_it == _Output_Service_file_map.end()) {
+ _t_Salome_file_map * _map = new _t_Salome_file_map();
+ _Output_Service_file_map[service_name] = _map;
+ }
+ _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+
+ // Try to find the Salome_file ...
+ _Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Salome_file_map_it == _map->end()) {
+ Salome_file_i * Sfile = new Salome_file_i();
+ Engines::Container_ptr container = this->GetContainerRef();
+ Sfile->setContainer(Engines::Container::_duplicate(container));
+ (*_map)[Salome_file_name] = Sfile;
+ }
+
+ Salome_file_i * Sfile = (*_map)[Salome_file_name];
+ return Sfile->_this();
+}
+
+void
+Engines_Component_i::checkOutputFilesToService(const char* service_name)
+{
+ // Try to find the service, if it doesn't exist, nothing to do.
+ _Service_file_map_it = _Output_Service_file_map.find(service_name);
+ if (_Service_file_map_it != _Output_Service_file_map.end()) {
+ _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+ _t_Salome_file_map::iterator begin = _map->begin();
+ _t_Salome_file_map::iterator end = _map->end();
+
+ for(;begin!=end;begin++) {
+ Salome_file_i * file = begin->second;
+ std::string file_port_name = begin->first;
+ configureSalome_file(service_name, file_port_name, file);
+ file->recvFiles();
+ }
+ }
+
+}
+
+//=============================================================================
+/*!
+ * C++ method: used to configure the Salome_file into the runtime.
+ * \param service_name name of the service that use this Salome_file
+ * \param file_port_name name of the Salome_file
+ * \param file Salome_file C++ object
+ */
+//=============================================================================
+void
+Engines_Component_i::configureSalome_file(std::string service_name,
+ std::string file_port_name,
+ Salome_file_i * file)
+{
+ // By default this method does nothing
+}
+
#include <SALOMEconfig.h>
//#ifndef WNT
#include CORBA_SERVER_HEADER(SALOME_Component)
+#include CORBA_SERVER_HEADER(SALOME_Exception)
//#else
//#include <SALOME_Component.hh>
//#endif
#include "SALOME_Component_i.hxx"
#include "SALOME_FileRef_i.hxx"
#include "SALOME_FileTransfer_i.hxx"
+#include "Salome_file_i.hxx"
#include "SALOME_NamingService.hxx"
#include "OpUtil.hxx"
//=============================================================================
Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb,
- PortableServer::POA_var poa,
- char *containerName ,
+ PortableServer::POA_var poa,
+ char *containerName ,
int argc , char* argv[],
- bool activAndRegist,
- bool isServantAloneInProcess
- ) :
+ bool activAndRegist,
+ bool isServantAloneInProcess
+ ) :
_numInstance(0),_isServantAloneInProcess(isServantAloneInProcess)
{
_pid = (long)getpid();
string hostname = GetHostname();
#ifndef WNT
MESSAGE(hostname << " " << getpid() <<
- " Engines_Container_i starting argc " <<
+ " Engines_Container_i starting argc " <<
_argc << " Thread " << pthread_self() ) ;
#else
MESSAGE(hostname << " " << _getpid() <<
- " Engines_Container_i starting argc " << _argc<< " Thread " << pthread_self().p ) ;
+ " Engines_Container_i starting argc " << _argc<< " Thread " << pthread_self().p ) ;
#endif
int i = 0 ;
_NS->init_orb( CORBA::ORB::_duplicate(_orb) ) ;
CORBA::Object_var obj=_poa->id_to_reference(*_id);
Engines::Container_var pCont
- = Engines::Container::_narrow(obj);
+ = Engines::Container::_narrow(obj);
_containerName = _NS->BuildContainerNameForNS(containerName,
- hostname.c_str());
+ hostname.c_str());
SCRUTE(_containerName);
_NS->Register(pCont, _containerName.c_str());
MESSAGE("Engines_Container_i::Engines_Container_i : Container name "
- << _containerName);
+ << _containerName);
// Python:
// import SALOME_Container
SCRUTE(myCommand);
if (!_isSupervContainer)
- {
+ {
#ifdef WNT
-// //Py_ACQUIRE_NEW_THREAD;
-// PyEval_AcquireLock();
-// /* It should not be possible for more than one thread state
-// to be used for a thread.*/
-// PyThreadState *myTstate = PyGILState_GetThisThreadState();
-// // if no thread state defined
-// if ( !myTstate )
-// myTstate = PyThreadState_New(KERNEL_PYTHON::_interp);
-// PyThreadState *myoldTstate = PyThreadState_Swap(myTstate);
-
- PyEval_AcquireLock();
- PyThreadState *myTstate = PyThreadState_New(KERNEL_PYTHON::_interp);
- PyThreadState *myoldTstate = PyThreadState_Swap(myTstate);
+
+ PyEval_AcquireLock();
+ PyThreadState *myTstate = PyThreadState_New(KERNEL_PYTHON::_interp);
+ PyThreadState *myoldTstate = PyThreadState_Swap(myTstate);
#else
- Py_ACQUIRE_NEW_THREAD;
+ Py_ACQUIRE_NEW_THREAD;
#endif
#ifdef WNT
- // mpv: this is temporary solution: there is a unregular crash if not
- //Sleep(2000);
- //
+ // mpv: this is temporary solution: there is a unregular crash if not
+ //Sleep(2000);
+ //
// first element is the path to Registry.dll, but it's wrong
- PyRun_SimpleString("import sys\n");
- PyRun_SimpleString("sys.path = sys.path[1:]\n");
+ PyRun_SimpleString("import sys\n");
+ PyRun_SimpleString("sys.path = sys.path[1:]\n");
#endif
- PyRun_SimpleString("import SALOME_Container\n");
- PyRun_SimpleString((char*)myCommand.c_str());
- Py_RELEASE_NEW_THREAD;
- }
+ PyRun_SimpleString("import SALOME_Container\n");
+ PyRun_SimpleString((char*)myCommand.c_str());
+ Py_RELEASE_NEW_THREAD;
+ }
fileTransfer_i* aFileTransfer = new fileTransfer_i();
_fileTransfer = Engines::fileTransfer::_narrow(aFileTransfer->_this());
PyObject *globals = PyModule_GetDict(mainmod);
PyObject *pyCont = PyDict_GetItemString(globals, "pyCont");
PyObject *result = PyObject_CallMethod(pyCont,
- "import_component",
- "s",componentName);
+ "import_component",
+ "s",componentName);
int ret= PyInt_AsLong(result);
SCRUTE(ret);
Py_RELEASE_NEW_THREAD;
if (ret) // import possible: Python component
- {
- _numInstanceMutex.lock() ; // lock to be alone (stl container write)
- _library_map[aCompName] = (void *)pyCont; // any non O value OK
- _numInstanceMutex.unlock() ;
- MESSAGE("import Python: "<<aCompName<<" OK");
- return true;
- }
+ {
+ _numInstanceMutex.lock() ; // lock to be alone (stl container write)
+ _library_map[aCompName] = (void *)pyCont; // any non O value OK
+ _numInstanceMutex.unlock() ;
+ MESSAGE("import Python: "<<aCompName<<" OK");
+ return true;
+ }
}
return false;
}
Engines::Component_ptr
Engines_Container_i::create_component_instance(const char*genericRegisterName,
- CORBA::Long studyId)
+ CORBA::Long studyId)
{
if (studyId < 0)
{
if (_library_map[aCompName]) // Python component
{
if (_isSupervContainer)
- {
- INFOS("Supervision Container does not support Python Component Engines");
- return Engines::Component::_nil();
- }
+ {
+ INFOS("Supervision Container does not support Python Component Engines");
+ return Engines::Component::_nil();
+ }
_numInstanceMutex.lock() ; // lock on the instance number
_numInstance++ ;
int numInstance = _numInstance ;
sprintf( aNumI , "%d" , numInstance ) ;
string instanceName = aCompName + "_inst_" + aNumI ;
string component_registerName =
- _containerName + "/" + instanceName;
+ _containerName + "/" + instanceName;
Py_ACQUIRE_NEW_THREAD;
PyObject *mainmod = PyImport_AddModule("__main__");
PyObject *globals = PyModule_GetDict(mainmod);
PyObject *pyCont = PyDict_GetItemString(globals, "pyCont");
PyObject *result = PyObject_CallMethod(pyCont,
- "create_component_instance",
- "ssl",
- aCompName.c_str(),
- instanceName.c_str(),
- studyId);
+ "create_component_instance",
+ "ssl",
+ aCompName.c_str(),
+ instanceName.c_str(),
+ studyId);
string iors = PyString_AsString(result);
SCRUTE(iors);
Py_RELEASE_NEW_THREAD;
if( iors!="" )
{
- CORBA::Object_var obj = _orb->string_to_object(iors.c_str());
- iobject = Engines::Component::_narrow( obj ) ;
+ CORBA::Object_var obj = _orb->string_to_object(iors.c_str());
+ iobject = Engines::Component::_narrow( obj ) ;
}
return iobject._retn();
}
else
{
iobject = createInstance(genericRegisterName,
- handle,
- studyId);
+ handle,
+ studyId);
return iobject._retn();
}
}
Engines::Component_ptr
Engines_Container_i::find_component_instance( const char* registeredName,
- CORBA::Long studyId)
+ CORBA::Long studyId)
{
Engines::Component_var anEngine = Engines::Component::_nil();
map<string,Engines::Component_var>::iterator itm =_listInstances_map.begin();
string instance = (*itm).first;
SCRUTE(instance);
if (instance.find(registeredName) == 0)
- {
- anEngine = (*itm).second;
- if (studyId == anEngine->getStudyId())
- {
- return anEngine._retn();
- }
- }
+ {
+ anEngine = (*itm).second;
+ if (studyId == anEngine->getStudyId())
+ {
+ return anEngine._retn();
+ }
+ }
itm++;
}
return anEngine._retn();
Engines::Component_ptr
Engines_Container_i::load_impl( const char* genericRegisterName,
- const char* componentName )
+ const char* componentName )
{
string impl_name = string ("lib") + genericRegisterName +string("Engine.so");
Engines::Component_var iobject = Engines::Component::_nil() ;
void *handle = (*ith).second;
string impl_name= (*ith).first;
if (handle)
- {
- SCRUTE(handle);
- SCRUTE(impl_name);
-// dlclose(handle); // SALOME unstable after ...
-// _library_map.erase(impl_name);
- }
+ {
+ SCRUTE(handle);
+ SCRUTE(impl_name);
+// dlclose(handle); // SALOME unstable after ...
+// _library_map.erase(impl_name);
+ }
}
_toRemove_map.clear();
_numInstanceMutex.unlock();
}
+Engines::Salome_file_ptr
+Engines_Container_i::createSalome_file(const char* origFileName)
+{
+ string origName(origFileName);
+ if (CORBA::is_nil(_Salome_file_map[origName]))
+ {
+ Salome_file_i* aSalome_file = new Salome_file_i();
+ aSalome_file->setContainer(Engines::Container::_duplicate(this->_this()));
+ try
+ {
+ aSalome_file->setLocalFile(origFileName);
+ aSalome_file->recvFiles();
+ }
+ catch (const SALOME::SALOME_Exception& e)
+ {
+ return Engines::Salome_file::_nil();
+ }
+
+ Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil();
+ theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this());
+ _numInstanceMutex.lock() ; // lock to be alone (stl container write)
+ _Salome_file_map[origName] = theSalome_file;
+ _numInstanceMutex.unlock() ;
+ }
+
+ Engines::Salome_file_ptr theSalome_file =
+ Engines::Salome_file::_duplicate(_Salome_file_map[origName]);
+ ASSERT(!CORBA::is_nil(theSalome_file));
+ return theSalome_file;
+}
//=============================================================================
/*!
* C++ method: Finds an already existing servant instance of a component, or
Engines::Component_ptr
Engines_Container_i::find_or_create_instance(string genericRegisterName,
- string componentLibraryName)
+ string componentLibraryName)
{
string aGenRegisterName = genericRegisterName;
string impl_name = componentLibraryName;
// --- find a registered instance in naming service, or create
string component_registerBase =
- _containerName + "/" + aGenRegisterName;
+ _containerName + "/" + aGenRegisterName;
Engines::Component_var iobject = Engines::Component::_nil() ;
try
- {
- CORBA::Object_var obj =
- _NS->ResolveFirst( component_registerBase.c_str());
- if ( CORBA::is_nil( obj ) )
- {
- iobject = createInstance(genericRegisterName,
- handle,
- 0); // force multiStudy instance here !
- }
- else
- {
- iobject = Engines::Component::_narrow( obj ) ;
- Engines_Component_i *servant =
- dynamic_cast<Engines_Component_i*>
- (_poa->reference_to_servant(iobject));
- ASSERT(servant)
- int studyId = servant->getStudyId();
- ASSERT (studyId >= 0);
- if (studyId == 0) // multiStudy instance, OK
- {
- // No ReBind !
- MESSAGE(component_registerBase.c_str()<<" already bound");
- }
- else // monoStudy instance: NOK
- {
- iobject = Engines::Component::_nil();
- INFOS("load_impl & find_component_instance methods "
- << "NOT SUITABLE for mono study components");
- }
- }
- }
+ {
+ CORBA::Object_var obj =
+ _NS->ResolveFirst( component_registerBase.c_str());
+ if ( CORBA::is_nil( obj ) )
+ {
+ iobject = createInstance(genericRegisterName,
+ handle,
+ 0); // force multiStudy instance here !
+ }
+ else
+ {
+ iobject = Engines::Component::_narrow( obj ) ;
+ Engines_Component_i *servant =
+ dynamic_cast<Engines_Component_i*>
+ (_poa->reference_to_servant(iobject));
+ ASSERT(servant)
+ int studyId = servant->getStudyId();
+ ASSERT (studyId >= 0);
+ if (studyId == 0) // multiStudy instance, OK
+ {
+ // No ReBind !
+ MESSAGE(component_registerBase.c_str()<<" already bound");
+ }
+ else // monoStudy instance: NOK
+ {
+ iobject = Engines::Component::_nil();
+ INFOS("load_impl & find_component_instance methods "
+ << "NOT SUITABLE for mono study components");
+ }
+ }
+ }
catch (...)
- {
- INFOS( "Container_i::load_impl catched" ) ;
- }
+ {
+ INFOS( "Container_i::load_impl catched" ) ;
+ }
return iobject._retn();
}
}
Engines::Component_ptr
Engines_Container_i::createInstance(string genericRegisterName,
- void *handle,
- int studyId)
+ void *handle,
+ int studyId)
{
// --- find the factory
sprintf( aNumI , "%d" , numInstance ) ;
string instanceName = aGenRegisterName + "_inst_" + aNumI ;
string component_registerName =
- _containerName + "/" + instanceName;
+ _containerName + "/" + instanceName;
// --- Instanciate required CORBA object
PortableServer::ObjectId *id ; //not owner, do not delete (nore use var)
id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str(),
- aGenRegisterName.c_str() ) ;
+ aGenRegisterName.c_str() ) ;
if (id == NULL)
- return iobject._retn();
+ return iobject._retn();
// --- get reference & servant from id
iobject = Engines::Component::_narrow( obj ) ;
Engines_Component_i *servant =
- dynamic_cast<Engines_Component_i*>(_poa->reference_to_servant(iobject));
+ dynamic_cast<Engines_Component_i*>(_poa->reference_to_servant(iobject));
ASSERT(servant);
//SCRUTE(servant->pd_refCount);
servant->_remove_ref(); // compensate previous id_to_reference
if (_cntInstances_map[aGenRegisterName] == 0)
{
string impl_name =
- Engines_Component_i::GetDynLibraryName(aGenRegisterName.c_str());
+ Engines_Component_i::GetDynLibraryName(aGenRegisterName.c_str());
SCRUTE(impl_name);
void* handle = _library_map[impl_name];
ASSERT(handle);
#ifndef WNT
void SigIntHandler(int what ,
- siginfo_t * siginfo ,
- void * toto )
+ siginfo_t * siginfo ,
+ void * toto )
{
//PAL9042 JR : during the execution of a Signal Handler (and of methods called through Signal Handlers)
// use of streams (and so on) should never be used because :
{
ActSigIntHandler() ;
if ( siginfo->si_signo == SIGUSR1 )
- {
- SetCpuUsed() ;
- }
+ {
+ SetCpuUsed() ;
+ }
else if ( siginfo->si_signo == SIGUSR2 )
- {
- CallCancelThread() ;
- }
+ {
+ CallCancelThread() ;
+ }
else
- {
- _Sleeping = true ;
- // MESSAGE("SigIntHandler BEGIN sleeping.") ;
- int count = 0 ;
- while( _Sleeping )
- {
- sleep( 1 ) ;
- count += 1 ;
- }
- // MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ;
- }
+ {
+ _Sleeping = true ;
+ // MESSAGE("SigIntHandler BEGIN sleeping.") ;
+ int count = 0 ;
+ while( _Sleeping )
+ {
+ sleep( 1 ) ;
+ count += 1 ;
+ }
+ // MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ;
+ }
return ;
}
}
{
ActSigIntHandler() ;
if ( what == SIGUSR1 )
- {
- SetCpuUsed() ;
- }
+ {
+ SetCpuUsed() ;
+ }
else
- {
- _Sleeping = true ;
- MESSAGE("SigIntHandler BEGIN sleeping.") ;
- int count = 0 ;
- while( _Sleeping )
- {
- Sleep( 1000 ) ;
- count += 1 ;
- }
- MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ;
- }
+ {
+ _Sleeping = true ;
+ MESSAGE("SigIntHandler BEGIN sleeping.") ;
+ int count = 0 ;
+ while( _Sleeping )
+ {
+ Sleep( 1000 ) ;
+ count += 1 ;
+ }
+ MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ;
+ }
return ;
}
}
SALOME_FileRef_i.hxx \
SALOME_ContainerManager.hxx \
Container_init_python.hxx \
- SALOME_Container.hxx
+ SALOME_Container.hxx \
+ Salome_file_i.hxx
# Scripts to be installed
dist_salomescript_DATA =\
COMMON_CPPFLAGS=\
@PYTHON_INCLUDES@ \
@MPI_INCLUDES@ \
- @CAS_CPPFLAGS@ @CAS_CXXFLAGS@ \
@QT_MT_INCLUDES@ \
-I$(srcdir)/../Basics \
-I$(srcdir)/../SALOMELocalTrace \
-I$(srcdir)/../Registry \
-I$(srcdir)/../Notification \
-I$(srcdir)/../ResourcesManager \
+ -I$(srcdir)/../HDFPersist \
-I$(top_builddir)/salome_adm/unix \
-I$(top_builddir)/idl \
@CORBA_CXXFLAGS@ @CORBA_INCLUDES@
../Utils/libOpUtil.la \
../SALOMELocalTrace/libSALOMELocalTrace.la \
../Basics/libSALOMEBasics.la \
+ ../HDFPersist/libSalomeHDFPersist.la \
$(top_builddir)/idl/libSalomeIDLKernel.la\
@MPI_LIBS@ \
@CORBA_LIBS@
SALOME_FileTransfer_i.cxx \
SALOME_FileRef_i.cxx \
Container_init_python.cxx \
- SALOME_ContainerManager.cxx
+ SALOME_ContainerManager.cxx \
+ Salome_file_i.cxx
libSalomeContainer_la_CPPFLAGS =\
$(COMMON_CPPFLAGS)
# ===============================================================
#
bin_PROGRAMS = SALOME_Container SALOME_ContainerManagerServer
+noinst_PROGRAMS = TestSalome_file
+
SALOME_Container_SOURCES =\
SALOME_Container.cxx \
SALOME_Container_SignalsHandler.cxx
$(COMMON_LIBS) \
../Basics/libSALOMEBasics.la
+SALOME_Container_LDFLAGS =\
+-Xlinker -export-dynamic
+
SALOME_ContainerManagerServer_SOURCES =\
SALOME_ContainerManagerServer.cxx
libSalomeContainer.la \
$(COMMON_LIBS) \
../Basics/libSALOMEBasics.la
+
+TestSalome_file_SOURCES =\
+ TestSalome_file.cxx
+
+TestSalome_file_CPPFLAGS =\
+ $(COMMON_CPPFLAGS)
+
+TestSalome_file_LDADD =\
+ libSalomeContainer.la \
+ $(COMMON_LIBS) \
+ ../Basics/libSALOMEBasics.la
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_Component)
#include "NOTIFICATION.hxx"
+#include "Salome_file_i.hxx"
class RegistryConnexion;
class Engines_Container_i;
CORBA::Boolean isPublished,
CORBA::Boolean& isValidScript);
+ // CORBA operations for Salome_file
+ virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name,
+ const char* Salome_file_name);
+ virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name,
+ const char* Salome_file_name);
+ virtual void checkInputFilesToService(const char* service_name);
+ virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name,
+ const char* Salome_file_name);
+
+ virtual void checkOutputFilesToService(const char* service_name);
+ virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name,
+ const char* Salome_file_name);
// --- local C++ methods
PortableServer::ObjectId * getId();
long CpuUsed() ;
void CancelThread() ;
+ virtual void configureSalome_file(std::string service_name,
+ std::string file_port_name,
+ Salome_file_i * file);
+
+
protected:
int _studyId; // -1: not initialised; 0: multiStudy; >0: study
static bool _isMultiStudy;
NOTIFICATION_Supplier* _notifSupplier;
std::map<std::string,CORBA::Any>_fieldsDict;
+ // Map Salome_file_name to Salome_file*
+ typedef std::map<std::string, Salome_file_i*> _t_Salome_file_map;
+ // Map Service_name to _Salome_file_map
+ typedef std::map<std::string, Engines_Component_i::_t_Salome_file_map*> _t_Service_file_map;
+
+ _t_Service_file_map _Input_Service_file_map;
+ _t_Service_file_map _Output_Service_file_map;
+ _t_Service_file_map::iterator _Service_file_map_it;
+ _t_Salome_file_map::iterator _Salome_file_map_it;
+
std::string _serviceName ;
std::string _graphName ;
std::string _nodeName ;
extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB);
+#include <stdexcept>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+typedef void (*sighandler_t)(int);
+sighandler_t setsig(int sig, sighandler_t handler)
+{
+ struct sigaction context, ocontext;
+ context.sa_handler = handler;
+ sigemptyset(&context.sa_mask);
+ context.sa_flags = 0;
+ if (sigaction(sig, &context, &ocontext) == -1)
+ return SIG_ERR;
+ return ocontext.sa_handler;
+}
+
+void AttachDebugger()
+{
+ if(getenv ("DEBUGGER"))
+ {
+ std::stringstream exec;
+ exec << "$DEBUGGER SALOME_Container " << getpid() << "&";
+ std::cerr << exec.str() << std::endl;
+ system(exec.str().c_str());
+ while(1);
+ }
+}
+
+void Handler(int theSigId)
+{
+ std::cerr << "SIGSEGV: " << std::endl;
+ AttachDebugger();
+ //to exit or not to exit
+ exit(1);
+}
+
+void terminateHandler(void)
+{
+ std::cerr << "Terminate: not managed exception !" << std::endl;
+ AttachDebugger();
+}
+
+void unexpectedHandler(void)
+{
+ std::cerr << "Unexpected: unexpected exception !" << std::endl;
+ AttachDebugger();
+}
+
int main(int argc, char* argv[])
{
#ifdef HAVE_MPI2
MPI_Init(&argc,&argv);
#endif
+ if(getenv ("DEBUGGER"))
+ {
+ setsig(SIGSEGV,&Handler);
+ set_terminate(&terminateHandler);
+ set_unexpected(&unexpectedHandler);
+ }
+
// Initialise the ORB.
//SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
//CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
const Engines::MachineList& possibleComputers,
Engines::ResPolicy policy)
{
+#ifdef WITH_PACO_PARALLEL
+ std::string parallelLib(params.parallelLib);
+ if (parallelLib != "")
+ return FindOrStartParallelContainer(params, possibleComputers);
+#endif
long id;
string containerNameInNS;
char idc[3*sizeof(long)];
INFOS("[FindOrStartParallelContainer] Starting a parallel container");
// Step 2.1 : Choose a computer
- string theMachine = _ResManager->FindBest(possibleComputers);
+ string theMachine = _ResManager->FindFirst(possibleComputers);
if(theMachine == "") {
INFOS("[FindOrStartParallelContainer] !!!!!!!!!!!!!!!!!!!!!!!!!!");
INFOS("[FindOrStartParallelContainer] No possible computer found");
Engines::fileRef_ptr createFileRef(const char* origFileName);
Engines::fileTransfer_ptr getFileTransfer();
-
+ virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
// --- local C++ methods
Engines::Component_ptr
int _numInstance ;
std::map<std::string,Engines::Component_var> _listInstances_map;
std::map<std::string,Engines::fileRef_var> _fileRef_map;
+ std::map<std::string,Engines::Salome_file_var> _Salome_file_map;
Engines::fileTransfer_var _fileTransfer;
int _argc ;
--- /dev/null
+// Copyright (C) 2007 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : Salome_file_i.cxx
+// Author : André RIBES, EDF
+// Module : SALOME
+// $Header:
+
+#include "Salome_file_i.hxx"
+#include "utilities.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include "HDFOI.hxx"
+#include <stdlib.h>
+
+//=============================================================================
+/*!
+ * Default constructor,
+ */
+//=============================================================================
+
+Salome_file_i::Salome_file_i()
+{
+ _fileId = 0;
+ _path_max = 1 + pathconf("/", _PC_PATH_MAX);
+ _state.name = CORBA::string_dup("");
+ _state.hdf5_file_name = CORBA::string_dup("");
+ _state.number_of_files = 0;
+ _state.files_ok = true;
+ _container = Engines::Container::_nil();
+ _default_source_Salome_file = Engines::Salome_file::_nil();
+}
+
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+
+Salome_file_i::~Salome_file_i()
+{
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::load
+ */
+//=============================================================================
+void
+Salome_file_i::load(const char* hdf5_file) {
+ _state.hdf5_file_name = CORBA::string_dup(hdf5_file);
+ try
+ {
+ HDFfile *hdf_file;
+ HDFgroup *hdf_group;
+ HDFdataset *hdf_dataset;
+ int size;
+ int fd;
+ char * value;
+ char * buffer;
+
+ hdf_file = new HDFfile((char*) hdf5_file);
+ hdf_file->OpenOnDisk(HDF_RDONLY);
+
+ hdf_group = new HDFgroup("CONFIG",hdf_file);
+ hdf_group->OpenOnDisk();
+ hdf_dataset = new HDFdataset("MODE",hdf_group);
+ hdf_dataset->OpenOnDisk();
+ size = hdf_dataset->GetSize();
+ value = new char[size];
+ hdf_dataset->ReadFromDisk(value);
+ hdf_dataset->CloseOnDisk();
+ std::string mode(value);
+ delete value;
+
+ hdf_group = new HDFgroup("GROUP_FILES",hdf_file);
+ hdf_group->OpenOnDisk();
+ hdf_dataset = new HDFdataset("LIST_OF_FILES",hdf_group);
+ hdf_dataset->OpenOnDisk();
+ size = hdf_dataset->GetSize();
+ value = new char[size];
+ hdf_dataset->ReadFromDisk(value);
+ hdf_dataset->CloseOnDisk();
+ std::string list_of_files(value);
+ delete value;
+
+ std::istringstream iss(list_of_files);
+ std::string file_name;
+ while (std::getline(iss, file_name, ' '))
+ {
+ std::string dataset_group_name("DATASET");
+ dataset_group_name += file_name;
+
+ hdf_group = new HDFgroup(dataset_group_name.c_str(), hdf_file);
+ hdf_group->OpenOnDisk();
+
+ hdf_dataset = new HDFdataset("NAME",hdf_group);
+ hdf_dataset->OpenOnDisk();
+ size = hdf_dataset->GetSize();
+ value = new char[size];
+ hdf_dataset->ReadFromDisk(value);
+ hdf_dataset->CloseOnDisk();
+ std::string name(value);
+
+ hdf_dataset = new HDFdataset("PATH",hdf_group);
+ hdf_dataset->OpenOnDisk();
+ size = hdf_dataset->GetSize();
+ value = new char[size];
+ hdf_dataset->ReadFromDisk(value);
+ hdf_dataset->CloseOnDisk();
+ std::string path(value);
+
+ hdf_dataset = new HDFdataset("TYPE",hdf_group);
+ hdf_dataset->OpenOnDisk();
+ size = hdf_dataset->GetSize();
+ value = new char[size];
+ hdf_dataset->ReadFromDisk(value);
+ hdf_dataset->CloseOnDisk();
+ std::string type(value);
+
+ hdf_dataset = new HDFdataset("SOURCE_FILE_NAME",hdf_group);
+ hdf_dataset->OpenOnDisk();
+ size = hdf_dataset->GetSize();
+ value = new char[size];
+ hdf_dataset->ReadFromDisk(value);
+ hdf_dataset->CloseOnDisk();
+ std::string source_file_name(value);
+
+ hdf_dataset = new HDFdataset("STATUS",hdf_group);
+ hdf_dataset->OpenOnDisk();
+ size = hdf_dataset->GetSize();
+ value = new char[size];
+ hdf_dataset->ReadFromDisk(value);
+ hdf_dataset->CloseOnDisk();
+ std::string status(value);
+
+ if (mode == "all") {
+
+ // Changing path, is now current directory
+ char CurrentPath[_path_max];
+ getcwd(CurrentPath, _path_max);
+ path = CurrentPath;
+
+ std::string group_name("GROUP");
+ group_name += file_name;
+ hdf_group = new HDFgroup(group_name.c_str(),hdf_file);
+ hdf_group->OpenOnDisk();
+ hdf_dataset = new HDFdataset("FILE DATASET",hdf_group);
+ hdf_dataset->OpenOnDisk();
+ size = hdf_dataset->GetSize();
+ buffer = new char[size];
+
+ if ( (fd = ::open(file_name.c_str(),O_RDWR|O_CREAT,00666)) <0) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "open failed";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ };
+ hdf_dataset->ReadFromDisk(buffer);
+ if ( write(fd,buffer,size) <0) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "write failed";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ };
+ // Close the target file
+ ::close(fd);
+
+ Engines::file infos;
+ infos.file_name = CORBA::string_dup(file_name.c_str());
+ infos.path = CORBA::string_dup(path.c_str());
+ infos.type = CORBA::string_dup(type.c_str());
+ infos.source_file_name = CORBA::string_dup(source_file_name.c_str());
+ infos.status = CORBA::string_dup(status.c_str());
+
+ _fileManaged[file_name] = infos;
+
+ // Update Salome_file state
+ _state.number_of_files++;
+ _state.files_ok = true;
+ }
+ else {
+ Engines::file infos;
+ infos.file_name = CORBA::string_dup(file_name.c_str());
+ infos.path = CORBA::string_dup(path.c_str());
+ infos.type = CORBA::string_dup(type.c_str());
+ infos.source_file_name = CORBA::string_dup(source_file_name.c_str());
+ infos.status = CORBA::string_dup(status.c_str());
+ // Infos for parallel extensions...
+ infos.node = 0;
+ infos.container = Engines::Container::_duplicate(_container);
+
+ _fileManaged[file_name] = infos;
+
+ // Update Salome_file state
+ _state.number_of_files++;
+ if (status != "ok")
+ _state.files_ok = false;
+ }
+ }
+ }
+ catch (HDFexception)
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "!!!! HDFexception";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::save
+ */
+//=============================================================================
+void
+Salome_file_i::save(const char* hdf5_file) {
+ _state.hdf5_file_name = CORBA::string_dup(hdf5_file);
+ try
+ {
+ HDFfile *hdf_file;
+ HDFgroup *hdf_group;
+ HDFdataset *hdf_dataset;
+ hdf_size size[1];
+ _t_fileManaged::iterator begin = _fileManaged.begin();
+ _t_fileManaged::iterator end = _fileManaged.end();
+
+ hdf_file = new HDFfile((char*) _state.hdf5_file_name.in());
+ hdf_file->CreateOnDisk();
+
+ // Save mode information
+ hdf_group = new HDFgroup("CONFIG", hdf_file);
+ hdf_group->CreateOnDisk();
+ std::string mode("infos");
+ size[0] = strlen(mode.c_str()) + 1;
+ hdf_dataset = new HDFdataset("MODE", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) mode.c_str());
+ hdf_dataset->CloseOnDisk();
+ hdf_group->CloseOnDisk();
+
+ // List of files that are managed
+ std::string list_of_files;
+ for(;begin!=end;begin++)
+ {
+ Engines::file file_infos = begin->second;
+ std::string file_name(file_infos.file_name.in());
+
+ list_of_files = list_of_files + file_name + std::string(" ");
+ }
+ hdf_group = new HDFgroup("GROUP_FILES", hdf_file);
+ hdf_group->CreateOnDisk();
+ size[0] = strlen(list_of_files.c_str()) + 1;
+ hdf_dataset = new HDFdataset("LIST_OF_FILES", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) list_of_files.c_str());
+ hdf_dataset->CloseOnDisk();
+ hdf_group->CloseOnDisk();
+
+ // Insert Files into the hdf5_file
+ begin = _fileManaged.begin();
+ for(;begin!=end;begin++)
+ {
+ Engines::file file_infos = begin->second;
+ std::string file_name(file_infos.file_name.in());
+ std::string comp_file_name(_fileManaged[file_name].path.in());
+ comp_file_name.append(_fileManaged[file_name].file_name.in());
+ std::string dataset_group_name("DATASET");
+ dataset_group_name += std::string(_fileManaged[file_name].file_name.in());
+
+ hdf_group = new HDFgroup((char *) dataset_group_name.c_str(), hdf_file);
+ hdf_group->CreateOnDisk();
+ size[0] = strlen(file_infos.file_name.in()) + 1;
+ hdf_dataset = new HDFdataset("NAME", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) file_infos.file_name.in());
+ hdf_dataset->CloseOnDisk();
+ size[0] = strlen(file_infos.path.in()) + 1;
+ hdf_dataset = new HDFdataset("PATH", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) file_infos.path.in());
+ hdf_dataset->CloseOnDisk();
+ size[0] = strlen(file_infos.type.in()) + 1;
+ hdf_dataset = new HDFdataset("TYPE", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) file_infos.type.in());
+ hdf_dataset->CloseOnDisk();
+ size[0] = strlen(file_infos.source_file_name.in()) + 1;
+ hdf_dataset = new HDFdataset("SOURCE_FILE_NAME", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) file_infos.source_file_name.in());
+ hdf_dataset->CloseOnDisk();
+ size[0] = strlen(file_infos.status.in()) + 1;
+ hdf_dataset = new HDFdataset("STATUS", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) file_infos.status.in());
+ hdf_dataset->CloseOnDisk();
+ hdf_group->CloseOnDisk();
+ }
+
+ hdf_file->CloseOnDisk();
+
+ // delete hdf_dataset;
+ // delete hdf_group; ----> SEGFAULT !!!
+ // delete hdf_file; ----> SEGFAULT !!!
+ }
+ catch (HDFexception)
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "!!!! HDFexception";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::save_all
+ */
+//=============================================================================
+void
+Salome_file_i::save_all(const char* hdf5_file) {
+
+ _state.hdf5_file_name = CORBA::string_dup(hdf5_file);
+ // Test Salome_file status
+ if (_state.files_ok == false) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "File Not Ok !";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+
+ // For each file we create two groups
+ // First group contains file's informations
+ // Second group contains the file
+ // At the end we create a group and a dataset containing the names
+ // of all the files.
+ try
+ {
+ HDFfile *hdf_file;
+ HDFgroup *hdf_group;
+ HDFdataset *hdf_dataset;
+ hdf_size size[1];
+ _t_fileManaged::iterator begin = _fileManaged.begin();
+ _t_fileManaged::iterator end = _fileManaged.end();
+
+ hdf_file = new HDFfile((char*) _state.hdf5_file_name.in());
+ hdf_file->CreateOnDisk();
+
+ // Save mode information
+ hdf_group = new HDFgroup("CONFIG", hdf_file);
+ hdf_group->CreateOnDisk();
+ std::string mode("all");
+ size[0] = strlen(mode.c_str()) + 1;
+ hdf_dataset = new HDFdataset("MODE", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) mode.c_str());
+ hdf_dataset->CloseOnDisk();
+ hdf_group->CloseOnDisk();
+
+
+ // List of files that will be inserted
+ std::string list_of_files;
+ for(;begin!=end;begin++)
+ {
+ Engines::file file_infos = begin->second;
+ std::string file_name(file_infos.file_name.in());
+
+ list_of_files = list_of_files + file_name + std::string(" ");
+ }
+ hdf_group = new HDFgroup("GROUP_FILES", hdf_file);
+ hdf_group->CreateOnDisk();
+ size[0] = strlen(list_of_files.c_str()) + 1;
+ hdf_dataset = new HDFdataset("LIST_OF_FILES", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) list_of_files.c_str());
+ hdf_dataset->CloseOnDisk();
+ hdf_group->CloseOnDisk();
+
+ // Insert Files into the hdf5_file
+ begin = _fileManaged.begin();
+ for(;begin!=end;begin++)
+ {
+ Engines::file file_infos = begin->second;
+ std::string file_name(file_infos.file_name.in());
+ std::string comp_file_name(_fileManaged[file_name].path.in());
+ comp_file_name.append(_fileManaged[file_name].file_name.in());
+ std::string group_name("GROUP");
+ group_name += std::string(_fileManaged[file_name].file_name.in());
+ std::string dataset_group_name("DATASET");
+ dataset_group_name += std::string(_fileManaged[file_name].file_name.in());
+
+ hdf_group = new HDFgroup((char *) group_name.c_str(), hdf_file);
+ hdf_group->CreateOnDisk();
+ HDFConvert::FromAscii(comp_file_name.c_str(), *hdf_group, "FILE DATASET");
+ hdf_group->CloseOnDisk();
+
+ hdf_group = new HDFgroup((char *) dataset_group_name.c_str(), hdf_file);
+ hdf_group->CreateOnDisk();
+ size[0] = strlen(file_infos.file_name.in()) + 1;
+ hdf_dataset = new HDFdataset("NAME", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) file_infos.file_name.in());
+ hdf_dataset->CloseOnDisk();
+ size[0] = strlen(file_infos.path.in()) + 1;
+ hdf_dataset = new HDFdataset("PATH", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) file_infos.path.in());
+ hdf_dataset->CloseOnDisk();
+ size[0] = strlen(file_infos.type.in()) + 1;
+ hdf_dataset = new HDFdataset("TYPE", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) file_infos.type.in());
+ hdf_dataset->CloseOnDisk();
+ size[0] = strlen(file_infos.source_file_name.in()) + 1;
+ hdf_dataset = new HDFdataset("SOURCE_FILE_NAME", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) file_infos.source_file_name.in());
+ hdf_dataset->CloseOnDisk();
+ size[0] = strlen(file_infos.status.in()) + 1;
+ hdf_dataset = new HDFdataset("STATUS", hdf_group, HDF_STRING, size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void *) file_infos.status.in());
+ hdf_dataset->CloseOnDisk();
+ hdf_group->CloseOnDisk();
+
+ }
+
+ hdf_file->CloseOnDisk();
+
+ // delete hdf_dataset;
+ // delete hdf_group; ----> SEGFAULT !!!
+ // delete hdf_file; ----> SEGFAULT !!!
+ }
+ catch (HDFexception)
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "!!!! HDFexception";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::setLocalFile
+ */
+//=============================================================================
+void
+Salome_file_i::setLocalFile(const char* comp_file_name)
+{
+ std::string file_name("");
+ std::string path("");
+ std::string type("local");
+ std::string source_file_name("");
+ std::string status("not_ok");
+
+ std::string cp_file_name(comp_file_name);
+ std::size_t index = cp_file_name.rfind("/");
+ if (index != -1)
+ {
+ file_name = cp_file_name.substr(index+1);
+ path = cp_file_name.substr(0,index+1);
+ }
+ else
+ {
+ file_name = comp_file_name;
+ char CurrentPath[_path_max];
+ getcwd(CurrentPath, _path_max);
+ path = CurrentPath;
+ }
+
+ // Test if this file is already added
+ _t_fileManaged::iterator it = _fileManaged.find(file_name);
+ if (it != _fileManaged.end())
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "file already added";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+
+ // Test if the file is ok
+ if(fopen(comp_file_name,"rb") != NULL)
+ status = "ok";
+
+ // Adding file with is informations
+ Engines::file infos;
+ infos.file_name = CORBA::string_dup(file_name.c_str());
+ infos.path = CORBA::string_dup(path.c_str());
+ infos.type = CORBA::string_dup(type.c_str());
+ infos.source_file_name = CORBA::string_dup(source_file_name.c_str());
+ infos.status = CORBA::string_dup(status.c_str());
+ // Infos for parallel extensions...
+ infos.node = 0;
+ infos.container = Engines::Container::_duplicate(_container);
+
+ _fileManaged[file_name] = infos;
+
+ // Update Salome_file state
+ _state.number_of_files++;
+ if (status != "ok")
+ _state.files_ok = false;
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::setDistributedFile
+ */
+//=============================================================================
+void
+Salome_file_i::setDistributedFile(const char* comp_file_name)
+{
+ std::string file_name("");
+ std::string path("");
+ std::string type("distributed");
+ std::string source_file_name("");
+ std::string status("not_ok");
+
+ std::string cp_file_name(comp_file_name);
+ std::size_t index = cp_file_name.rfind("/");
+ if (index != -1)
+ {
+ file_name = cp_file_name.substr(index+1);
+ path = cp_file_name.substr(0,index+1);
+ }
+ else
+ {
+ file_name = comp_file_name;
+ char CurrentPath[_path_max];
+ getcwd(CurrentPath, _path_max);
+ path = CurrentPath;
+ }
+
+ // Test if this file is already added
+ _t_fileManaged::iterator it = _fileManaged.find(file_name);
+ if (it != _fileManaged.end())
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "file already added";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+
+ // Adding file with his informations
+ Engines::file infos;
+ infos.file_name = CORBA::string_dup(file_name.c_str());
+ infos.path = CORBA::string_dup(path.c_str());
+ infos.type = CORBA::string_dup(type.c_str());
+ infos.source_file_name = CORBA::string_dup(source_file_name.c_str());
+ infos.status = CORBA::string_dup(status.c_str());
+ // Infos for parallel extensions...
+ infos.node = 0;
+ infos.container = Engines::Container::_duplicate(_container);
+
+ _fileManaged[file_name] = infos;
+
+ if(!CORBA::is_nil(_default_source_Salome_file))
+ {
+ _fileDistributedSource[file_name] =
+ Engines::Salome_file::_duplicate(_default_source_Salome_file);
+ }
+
+ // Update Salome_file state
+ _state.number_of_files++;
+ _state.files_ok = false;
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::connect
+ */
+//=============================================================================
+void
+Salome_file_i::connect(Engines::Salome_file_ptr source_Salome_file)
+{
+ if(CORBA::is_nil(_default_source_Salome_file))
+ {
+ _default_source_Salome_file = Engines::Salome_file::_duplicate(source_Salome_file);
+ _t_fileManaged::iterator begin = _fileManaged.begin();
+ _t_fileManaged::iterator end = _fileManaged.end();
+ for(;begin!=end;begin++) {
+ // Get the name of the file
+ std::string file_name = begin->first;
+ _t_fileDistributedSource::iterator it = _fileDistributedSource.find(file_name);
+ if (it == _fileDistributedSource.end())
+ {
+ _fileDistributedSource[file_name] = Engines::Salome_file::_duplicate(source_Salome_file);
+ }
+ }
+ }
+ else
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "already connected to a default Salome_file";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+ // We can connect this Salome_file if there is only one file managed
+ // by the Salome_file
+ //std::string fname;
+ //if (_fileManaged.size() == 1)
+ //{
+ // only one file managed
+ // _t_fileManaged::iterator it = _fileManaged.begin();
+ // fname = it->first;
+ // _fileDistributedSource[fname] = Engines::Salome_file::_duplicate(source_Salome_file);
+ //}
+ //else
+ //{
+ // SALOME::ExceptionStruct es;
+ // es.type = SALOME::INTERNAL_ERROR;
+ // std::string text = "cannot connect";
+ // es.text = CORBA::string_dup(text.c_str());
+ // throw SALOME::SALOME_Exception(es);
+ //}
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::connectDistributedFile
+ */
+//=============================================================================
+void
+Salome_file_i::connectDistributedFile(const char * file_name,
+ Engines::Salome_file_ptr source_Salome_file)
+{
+ // Test if this file is added
+ _t_fileManaged::iterator it = _fileManaged.find(file_name);
+ if (it == _fileManaged.end())
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "file is not added";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+ else
+ {
+ _fileDistributedSource[file_name] = Engines::Salome_file::_duplicate(source_Salome_file);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::setDistributedSourceFile
+ */
+//=============================================================================
+void
+Salome_file_i::setDistributedSourceFile(const char* file_name,
+ const char * source_file_name)
+{
+ std::string fname(file_name);
+
+ // Test if this file is added
+ _t_fileManaged::iterator it = _fileManaged.find(fname);
+ if (it == _fileManaged.end())
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "file is not added";
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+ else
+ {
+ _fileManaged[fname].source_file_name = CORBA::string_dup(source_file_name);
+ }
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::recvFiles
+ */
+//=============================================================================
+void
+Salome_file_i::recvFiles() {
+
+ std::string files_not_ok("");
+
+ _t_fileManaged::iterator begin = _fileManaged.begin();
+ _t_fileManaged::iterator end = _fileManaged.end();
+ for(;begin!=end;begin++)
+ {
+ bool result = true;
+ Engines::file file_infos = begin->second;
+ // Test if the file is local or distributed
+ if (std::string(file_infos.type.in()) == "local")
+ {
+ if (std::string(file_infos.status.in()) == "not_ok")
+ result = checkLocalFile(file_infos.file_name.in());
+ }
+ else
+ {
+ if (std::string(file_infos.status.in()) == "not_ok")
+ result = getDistributedFile(file_infos.file_name.in());
+ }
+ // if the result is false
+ // we add this file to files_not_ok
+ if (!result)
+ {
+ files_not_ok.append(" ");
+ files_not_ok.append(file_infos.file_name.in());
+ }
+ }
+
+ if (files_not_ok != "")
+ {
+ std::cerr << "tutu" << std::endl;
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "files not ready : " + files_not_ok;
+ es.text = CORBA::string_dup(text.c_str());
+ std::cerr << "titi" << std::endl;
+ throw SALOME::SALOME_Exception(es);
+ }
+ else
+ {
+ // We change the state of the Salome_file
+ _state.files_ok = true;
+ }
+}
+
+//=============================================================================
+/*!
+ * local C++ method : This method is used by revFiles to check if a local
+ * managed file is ok.
+ * \param fileName name of the file
+ */
+//=============================================================================
+bool
+Salome_file_i::checkLocalFile(std::string file_name)
+{
+ bool result = true;
+
+ std::string comp_file_name(_fileManaged[file_name].path.in());
+ comp_file_name.append("/");
+ comp_file_name.append(_fileManaged[file_name].file_name.in());
+ if(fopen(comp_file_name.c_str(),"rb") == NULL)
+ {
+ INFOS("file " << comp_file_name << " cannot be open for reading");
+ _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+ result = false;
+ }
+
+ if (result)
+ {
+ _fileManaged[file_name].status = CORBA::string_dup("ok");
+ }
+ return result;
+}
+
+//=============================================================================
+/*!
+ * local C++ method : this method is used by recvFiles to get a
+ * distributed file from is distributed source.
+ * If there is no source_file_name for the file, it tries to get
+ * the file from the source. In this case, the source distributed file has to managed
+ * only one file to be able to the send the file.
+ *
+ * \param fileName name of the file
+ */
+//=============================================================================
+bool
+Salome_file_i::getDistributedFile(std::string file_name)
+{
+ bool result = true;
+ const char * source_file_name = _fileManaged[file_name].source_file_name.in();
+ int fileId;
+ FILE* fp;
+ std::string comp_file_name(_fileManaged[file_name].path.in());
+ comp_file_name.append("/");
+ comp_file_name.append(_fileManaged[file_name].file_name.in());
+
+ // Test if the process can write on disk
+ if ((fp = fopen(comp_file_name.c_str(),"wb")) == NULL)
+ {
+ INFOS("file " << comp_file_name << " cannot be open for writing");
+ _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+ result = false;
+ return result;
+ }
+
+ try
+ {
+ fileId = _fileDistributedSource[file_name]->open(source_file_name);
+ }
+ catch (...)
+ {
+ _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+ fclose(fp);
+ result = false;
+ return result;
+ }
+
+ if (fileId > 0)
+ {
+ Engines::fileBlock* aBlock;
+ int toFollow = 1;
+ int ctr=0;
+ MESSAGE("begin of transfer of " << comp_file_name);
+ while (toFollow)
+ {
+ ctr++;
+ aBlock = _fileDistributedSource[file_name]->getBlock(fileId);
+ toFollow = aBlock->length();
+ CORBA::Octet *buf = aBlock->get_buffer();
+ int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
+ ASSERT(nbWri == toFollow);
+ }
+ fclose(fp);
+ MESSAGE("end of transfer of " << comp_file_name);
+ _fileDistributedSource[file_name]->close(fileId);
+ }
+ else
+ {
+ INFOS("open reference file for copy impossible");
+ result = false;
+ fclose(fp);
+ _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+ return result;
+ }
+
+ _fileManaged[file_name].status = CORBA::string_dup("ok");
+ return result;
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::removeFile
+ */
+//=============================================================================
+void
+Salome_file_i::removeFile(const char* file_name)
+{
+ MESSAGE("Salome_file_i::removeFile : NOT YET IMPLEMENTED");
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::removeFiles
+ */
+//=============================================================================
+void
+Salome_file_i::removeFiles() {
+ MESSAGE("Salome_file_i::removeFiles : NOT YET IMPLEMENTED");
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::getFilesInfos
+ */
+//=============================================================================
+Engines::files*
+Salome_file_i::getFilesInfos() {
+
+ Engines::files * infos = new Engines::files();
+ infos->length(_fileManaged.size());
+
+ _t_fileManaged::iterator begin = _fileManaged.begin();
+ _t_fileManaged::iterator end = _fileManaged.end();
+ int i = 0;
+ for(;begin!=end;begin++) {
+ (*infos)[i] = *(new Engines::file(begin->second));
+ i++;
+ }
+ return infos;
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::getFileInfos
+ */
+//=============================================================================
+Engines::file*
+Salome_file_i::getFileInfos(const char* file_name) {
+
+ std::string fname(file_name);
+
+ // Test if this file is managed
+ _t_fileManaged::iterator it = _fileManaged.find(fname);
+ if (it == _fileManaged.end())
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "file is not managed";
+ throw SALOME::SALOME_Exception(es);
+ }
+
+ Engines::file * infos = new Engines::file(_fileManaged[fname]);
+ return infos;
+}
+
+//=============================================================================
+/*!
+ * CORBA method
+ * \see Engines::Salome_file::getSalome_fileState
+ */
+//=============================================================================
+Engines::SfState*
+Salome_file_i::getSalome_fileState()
+{
+ return new Engines::SfState(_state);
+}
+
+//=============================================================================
+/*!
+ * CORBA method: try to open the file given. If the file is readable, return
+ * a positive integer else return 0;
+ * \param fileName file name to be transfered
+ * \return fileId = positive integer > 0 if open OK.
+ */
+//=============================================================================
+
+CORBA::Long
+Salome_file_i::open(const char* file_name)
+{
+ int aKey = 0;
+
+ std::string fname(file_name);
+ if (fname == "") {
+ // We enter in the simple case where the user
+ // has not used setDistributedSourceFile.
+ // In this case we try to see if the Salome_file
+ if (_fileManaged.size() == 1)
+ {
+ // only one file managed
+ _t_fileManaged::iterator it = _fileManaged.begin();
+ fname = it->first;
+ }
+ else
+ {
+ // we can't choose the file so :
+ return aKey;
+ }
+ }
+
+ _t_fileManaged::iterator it = _fileManaged.find(fname);
+ if (it == _fileManaged.end())
+ {
+ return aKey;
+ }
+
+ std::string comp_file_name(_fileManaged[fname].path.in());
+ comp_file_name.append("/");
+ comp_file_name.append(fname);
+ MESSAGE("Salome_file_i::open " << comp_file_name);
+ FILE* fp;
+ if ((fp = fopen(comp_file_name.c_str(),"rb")) == NULL)
+ {
+ INFOS("file " << comp_file_name << " is not readable");
+ return aKey;
+ }
+
+ aKey = ++_fileId;
+ _fileAccess[aKey] = fp;
+ return aKey;
+}
+
+//=============================================================================
+/*!
+ * CORBA method: close the file associated to the fileId given at open.
+ * \param fileId got in return from open method
+ */
+//=============================================================================
+
+void
+Salome_file_i::close(CORBA::Long fileId)
+{
+ MESSAGE("Salome_file_i::close");
+ FILE* fp;
+ if (!(fp = _fileAccess[fileId]) )
+ {
+ INFOS(" no FILE structure associated to fileId " << fileId);
+ }
+ else fclose(fp);
+}
+
+//=============================================================================
+/*!
+ * CORBA method: get a block of data from the file associated to the fileId
+ * given at open.
+ * \param fileId got in return from open method
+ * \return an octet sequence. Last one is empty.
+ */
+//=============================================================================
+
+#define FILEBLOCK_SIZE 256*1024
+
+Engines::fileBlock*
+Salome_file_i::getBlock(CORBA::Long fileId)
+{
+ Engines::fileBlock* aBlock = new Engines::fileBlock;
+
+ FILE* fp;
+ if (! (fp = _fileAccess[fileId]) )
+ {
+ INFOS(" no FILE structure associated to fileId " <<fileId);
+ return aBlock;
+ }
+
+ // use replace member function for sequence to avoid copy
+ // see Advanced CORBA Programming with C++ pp 187-194
+ CORBA::Octet *buf;
+ buf = Engines::fileBlock::allocbuf(FILEBLOCK_SIZE);
+ int nbRed = fread(buf, sizeof(CORBA::Octet), FILEBLOCK_SIZE, fp);
+ aBlock->replace(nbRed, nbRed, buf, 1); // 1 means give ownership
+ return aBlock;
+}
+
+void
+Salome_file_i::setContainer(Engines::Container_ptr container)
+{
+ _container = Engines::Container::_duplicate(container);
+
+ // Update All the files
+ _t_fileManaged::iterator begin = _fileManaged.begin();
+ _t_fileManaged::iterator end = _fileManaged.end();
+ for(;begin!=end;begin++) {
+ begin->second.container = Engines::Container::_duplicate(container);
+ }
+}
+
--- /dev/null
+// Copyright (C) 2007 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : Salome_file_i.hxx
+// Author : André RIBES, EDF
+// Module : SALOME
+// $Header:
+
+#ifndef _SALOME_FILE_I_HXX_
+#define _SALOME_FILE_I_HXX_
+
+#include <SALOMEconfig.h>
+
+#include CORBA_SERVER_HEADER(SALOME_Component)
+#include CORBA_SERVER_HEADER(SALOME_Exception)
+
+#include <SALOME_Container.hxx>
+#include <map>
+#include <cstdio>
+
+class CONTAINER_EXPORT Salome_file_i:
+ public virtual POA_Engines::Salome_file
+{
+ public:
+ Salome_file_i();
+ virtual ~Salome_file_i();
+
+ // Import and export methods
+ virtual void load(const char* hdf5_file);
+ virtual void save(const char* hdf5_file);
+ virtual void save_all(const char* hdf5_file);
+
+ // Adding files
+ virtual void setLocalFile(const char* comp_file_name);
+ virtual void setDistributedFile(const char* comp_file_name);
+
+ // Configure DistributedFile
+ virtual void connect(Engines::Salome_file_ptr source_Salome_file);
+ virtual void connectDistributedFile(const char * file_name,
+ Engines::Salome_file_ptr source_Salome_file);
+ virtual void setDistributedSourceFile(const char* file_name,
+ const char * source_file_name);
+
+ // Recv and check files
+ virtual void recvFiles();
+
+ // Removing or deleting files
+ virtual void removeFile(const char* file_name);
+ virtual void removeFiles();
+
+ // Informations methods:
+ virtual void setContainer(Engines::Container_ptr container);
+ virtual Engines::files* getFilesInfos();
+ virtual Engines::file* getFileInfos(const char* file_name);
+ virtual Engines::SfState* getSalome_fileState();
+
+ // ---------------- fileTransfert Methods -----------------------
+ virtual CORBA::Long open(const char* file_name);
+ virtual void close(CORBA::Long fileId);
+ virtual Engines::fileBlock* getBlock(CORBA::Long fileId);
+
+ protected:
+ // ---------------- local C++ methods ---------------------------
+ virtual bool checkLocalFile(std::string file_name);
+ virtual bool getDistributedFile(std::string file_name);
+
+ protected:
+
+ // Contains a relation between a file ID (int) with
+ // a fd descriptor (FILE*) open on the file.
+ typedef std::map<int, FILE*> _t_fileAccess;
+
+ // Contains the informations of the files managed by the Salome_file.
+ typedef std::map<std::string, Engines::file> _t_fileManaged;
+
+ // Contains the CORBA reference for each distributed file managed.
+ typedef std::map<std::string, Engines::Salome_file_var> _t_fileDistributedSource;
+
+ int _fileId;
+ long _path_max;
+ _t_fileAccess _fileAccess;
+ _t_fileManaged _fileManaged;
+ _t_fileDistributedSource _fileDistributedSource;
+ Engines::SfState _state;
+ Engines::Container_ptr _container;
+ Engines::Salome_file_ptr _default_source_Salome_file;
+};
+
+#endif
--- /dev/null
+#include "Salome_file_i.hxx"
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include "HDFascii.hxx"
+
+using namespace std;
+
+void print_infos(Engines::file * infos)
+{
+ cerr << "-------------------------------------------------------------------" << endl;
+ cerr << "file_name = " << infos->file_name << endl;
+ cerr << "path = " << infos->path << endl;
+ cerr << "type = " << infos->type << endl;
+ cerr << "source_file_name = " << infos->source_file_name << endl;
+ cerr << "status = " << infos->status << endl;
+}
+
+void print_state(Engines::SfState * state)
+{
+ cerr << "-------------------------------------------------------------------" << endl;
+ cerr << "name = " << state->name << endl;
+ cerr << "hdf5_file_name = " << state->hdf5_file_name << endl;
+ cerr << "number_of_files = " << state->number_of_files << endl;
+ cerr << "files_ok = " << state->files_ok << endl;
+}
+
+
+int main (int argc, char * argv[])
+{
+ system("rm toto cat test.hdf test2.hdf");
+
+ Salome_file_i file;
+ Salome_file_i file2;
+ Salome_file_i file3;
+ Salome_file_i file4;
+ Salome_file_i file5;
+ Engines::file * infos;
+ Engines::SfState * state;
+ Engines::files * all_infos;
+ PortableServer::POA_var root_poa;
+ PortableServer::POAManager_var pman;
+ CORBA::Object_var obj;
+
+ cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+ cerr << "Test of setLocalFile()" << endl;
+ file.setLocalFile("/tmp/toto");
+ infos = file.getFileInfos("toto");
+ print_infos(infos);
+
+
+ cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+ cerr << "Test of getFilesInfos()" << endl;
+ all_infos = file.getFilesInfos();
+ for (int i = 0; i < all_infos->length(); i++)
+ {
+ print_infos(&((*all_infos)[i]));
+ }
+
+ cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+ cerr << "Test of getSalome_fileState()" << endl;
+ state = file.getSalome_fileState();
+ print_state(state);
+
+ // We start CORBA ...
+ CORBA::ORB_ptr orb = CORBA::ORB_init(argc , argv);
+ obj = orb->resolve_initial_references("RootPOA");
+ root_poa = PortableServer::POA::_narrow(obj);
+ pman = root_poa->the_POAManager();
+ pman->activate();
+
+ file2.setLocalFile("/tmp/toto_distributed_source");
+ Engines::Salome_file_ptr file2_ref = file2._this();
+
+ cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+ cerr << "Test of setDistributedFile()" << endl;
+ file.setDistributedFile("/tmp/toto_distributed");
+ file.connectDistributedFile("toto_distributed", file2_ref);
+// file.setDistributedSourceFile("toto_distributed", "toto_distributed_source");
+ infos = file.getFileInfos("toto_distributed");
+ print_infos(infos);
+
+ // We create the files ...
+ std::ostringstream oss;
+ oss << "/tmp/toto";
+ std::ofstream f(oss.str().c_str());
+ if (f)
+ f << "blablabla" << std::endl;
+
+ std::ostringstream oss2;
+ oss2 << "/tmp/toto_distributed_source";
+ std::ofstream f2(oss2.str().c_str());
+ if (f2)
+ f2 << "bliblibli" << std::endl;
+
+ try
+ {
+ file.recvFiles();
+ }
+ catch (SALOME::SALOME_Exception & e)
+ {
+ cerr << "Exception : " << e.details.text << endl;
+ }
+
+ cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+ cerr << "Test of getFilesInfos()" << endl;
+ all_infos = file.getFilesInfos();
+ for (int i = 0; i < all_infos->length(); i++)
+ {
+ print_infos(&((*all_infos)[i]));
+ }
+
+ cerr << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
+ cerr << "Test of getSalome_fileState()" << endl;
+ state = file.getSalome_fileState();
+ print_state(state);
+
+ orb->destroy();
+
+ file3.setLocalFile("/tmp/toto");
+ file3.setLocalFile("/bin/cat");
+ state = file3.getSalome_fileState();
+ print_state(state);
+ file3.save_all("test.hdf");
+ file3.setLocalFile("/bin/tutu");
+ file3.save("test2.hdf");
+
+ file4.load("test.hdf");
+ all_infos = file4.getFilesInfos();
+ for (int i = 0; i < all_infos->length(); i++)
+ {
+ print_infos(&((*all_infos)[i]));
+ }
+ state = file4.getSalome_fileState();
+ print_state(state);
+ file5.load("test2.hdf");
+ all_infos = file5.getFilesInfos();
+ for (int i = 0; i < all_infos->length(); i++)
+ {
+ print_infos(&((*all_infos)[i]));
+ }
+ state = file5.getSalome_fileState();
+ print_state(state);
+
+ // Test of ConvertFromHDFToASCII
+ // and ConvertFromASCIIToHDF
+ cerr << "Test of ConvertFromASCIIToHDF" << endl;
+ HDFascii::ConvertFromASCIIToHDF("/tmp/toto"); // RETURN NULL !
+ cerr << "Test of ConvertFromHDFToASCII" << endl;
+ cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", false) << endl;
+ cerr << HDFascii::ConvertFromHDFToASCII("test2.hdf", true) << endl;
+
+ cerr << "End of tests" << endl;
+}
#define DSC_BASIC_EXPORT
#endif
-#endif
\ No newline at end of file
+#endif
+
--- /dev/null
+# 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 : Makefile.am
+# Author : André RIBES (EDF), Eric Fayolle (EDF)
+# Module : KERNEL
+#
+
+include $(top_srcdir)/salome_adm/unix/make_common_starter.am
+
+# ===============================================================
+# Local definitions
+# ===============================================================
+#
+
+# This local variable defines the list of CPPFLAGS common to all target in this package.
+COMMON_CPPFLAGS= -I$(top_srcdir)/src/DSC/DSC_User \
+ -I$(top_srcdir)/src/DSC/DSC_User/Datastream \
+ -I$(top_srcdir)/src/DSC/DSC_User/Datastream/Palm \
+ -I$(top_srcdir)/src/DSC/DSC_User/Datastream/Calcium \
+ -I$(top_srcdir)/src/DSC/DSC_User/Basic \
+ -I$(top_srcdir)/src/DSC/DSC_Basic \
+ -I$(top_srcdir)/src/SALOMELocalTrace \
+ -I$(top_srcdir)/src/Basics \
+ -I$(top_srcdir)/src/Utils \
+ -I$(top_srcdir)/src/Container \
+ -I$(top_srcdir)/src/Notification \
+ -I$(top_builddir)/salome_adm/unix \
+ -I$(top_builddir)/idl \
+ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @BOOST_CPPFLAGS@
+
+# This local variable defines the list of dependant libraries common to all target in this package.
+COMMON_LIBS = @CORBA_LIBS@
+
+#
+# ===============================================================
+# Libraries targets
+# ===============================================================
+#
+
+AM_CFLAGS = -fexceptions
+pkgpython_PYTHON = calcium.py dsccalcium.py
+pkgpyexec_LTLIBRARIES = _calcium.la
+SWIG_FLAGS= -python -c++ -noexcept
+SWIG_SRC=calcium.i
+_calcium_la_SOURCES = calcium_wrap.cpp
+_calcium_la_LDFLAGS = -module
+_calcium_la_LIBADD = ../DSC_User/Datastream/Calcium/libCalciumC.la \
+ ../DSC_User/Datastream/libSalomeDatastream.la \
+ ../DSC_User/Basic/libSalomeDSCSupervBasic.la \
+ ../DSC_User/libSalomeDSCSuperv.la \
+ ../DSC_Basic/libSalomeDSCContainer.la \
+ ../../Container/libSalomeContainer.la
+
+_calcium_la_CXXFLAGS = $(PYTHON_INCLUDES) $(COMMON_CPPFLAGS)
+
+calcium_wrap.cpp calcium.py:calcium.i
+ $(SWIG) $(SWIG_FLAGS) -o calcium_wrap.cpp $<
+
+CLEANFILES = calcium_wrap.cpp
+
--- /dev/null
+%define DOCSTRING
+"CALCIUM python wrapping : Superv_Component class
+"
+%enddef
+
+%module(docstring=DOCSTRING) calcium
+
+%feature("autodoc", "0");
+
+%{
+//C++ Includes
+#include <Calcium.hxx>
+#include <calcium.h>
+#include <Superv_Component_i.hxx>
+#include <omniORB4/CORBA.h>
+
+//--- from omniORBpy.h (not present on Debian Sarge packages)
+
+struct omniORBpyAPI {
+
+ PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj,
+ CORBA::Boolean hold_lock);
+ // Convert a C++ object reference to a Python object reference.
+ // If <hold_lock> is true, caller holds the Python interpreter lock.
+
+ CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj,
+ CORBA::Boolean hold_lock);
+ // Convert a Python object reference to a C++ object reference.
+ // Raises BAD_PARAM if the Python object is not an object reference.
+ // If <hold_lock> is true, caller holds the Python interpreter lock.
+
+
+ omniORBpyAPI();
+ // Constructor for the singleton. Sets up the function pointers.
+};
+
+ omniORBpyAPI* api;
+
+%}
+
+%init
+%{
+ // init section
+
+ PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
+ if (!omnipy)
+ {
+ PyErr_SetString(PyExc_ImportError,
+ (char*)"Cannot import _omnipy");
+ return;
+ }
+ PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
+ api = (omniORBpyAPI*)PyCObject_AsVoidPtr(pyapi);
+ Py_DECREF(pyapi);
+%}
+
+%include "carrays.i"
+%include "cpointer.i"
+
+/* Wrap a class interface around an "int *" */
+%pointer_class(int, intp);
+/* Wrap a class interface around an "float *" */
+%pointer_class(float, floatp);
+/* Wrap a class interface around an "double *" */
+%pointer_class(double, doublep);
+
+%array_class(int, intArray);
+%array_class(float, floatArray);
+%array_class(double, doubleArray);
+
+%typemap(python,in) CORBA::Boolean
+{
+ $1=(CORBA::Boolean)PyInt_AsLong($input);
+}
+
+%typemap(python,in) CORBA::ORB_ptr
+{
+ try {
+ CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1);
+ $1 = CORBA::ORB::_narrow(obj);
+ }
+ catch (...) {
+ PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr");
+ }
+}
+%typemap(python,in) PortableServer::POA_ptr
+{
+ 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");
+ }
+}
+
+%typemap(python,in) Engines::Container_ptr
+{
+ try {
+ CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1);
+ $1 = Engines::Container::_narrow(obj);
+ }
+ catch (...) {
+ PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr");
+ }
+}
+%typemap(python,in) 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");
+ }
+}
+
+%typemap(python,out) Ports::Port_ptr , Ports::PortProperties_ptr
+{
+ $result = api->cxxObjRefToPyObjRef($1, 1);
+}
+
+/*
+ * Exception section
+ */
+// a general exception handler
+%exception {
+ try {
+ $action
+ } catch(Engines::DSC::PortNotDefined& _e) {
+ PyErr_SetString(PyExc_ValueError,"Port not defined");
+ return NULL;
+ } catch(Engines::DSC::PortNotConnected& _e) {
+ PyErr_SetString(PyExc_ValueError,"Port not connected");
+ return NULL;
+ } catch(Engines::DSC::BadPortType& _e) {
+ PyErr_SetString(PyExc_ValueError,"Bad port type");
+ return NULL;
+ } catch(...) {
+ PyErr_SetString(PyExc_ValueError,"Unknown exception");
+ return NULL;
+ }
+}
+
+/*
+ * End of Exception section
+ */
+namespace Engines
+{
+class DSC
+{
+ public:
+ enum Message { AddingConnection, RemovingConnection, ApplicationError };
+};
+}
+
+class PySupervCompo:public Superv_Component_i
+{
+ public:
+
+ PySupervCompo(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ Engines::Container_ptr contai,
+ const char *instanceName,
+ const char *interfaceName);
+
+ virtual ~PySupervCompo();
+ CORBA::Boolean init_service(const char * service_name){return true;};
+ virtual provides_port * create_provides_data_port(const char* port_fab_type)
+ throw (BadFabType);
+ virtual uses_port * create_uses_data_port(const char* port_fab_type)
+ throw (BadFabType);
+ virtual void add_port(const char * port_fab_type,
+ const char * port_type,
+ const char * port_name)
+ throw (PortAlreadyDefined, BadFabType, BadType, BadProperty);
+ template < typename SpecificPortType >
+ SpecificPortType * add_port(const char * port_fab_type,
+ const char * port_type,
+ const char * port_name)
+ throw (PortAlreadyDefined, BadFabType, BadType, BadCast, BadProperty);
+ virtual void add_port(provides_port * port,
+ const char* provides_port_name)
+ throw (PortAlreadyDefined, NilPort, BadProperty);
+ virtual void add_port(uses_port * port,
+ const char* uses_port_name)
+ throw (PortAlreadyDefined, NilPort, BadProperty);
+ template <typename SpecificPortType >
+ SpecificPortType * get_port( const char * port_name)
+ throw (PortNotDefined, PortNotConnected, BadCast, UnexpectedState);
+ virtual Ports::Port_ptr get_provides_port(const char* provides_port_name,
+ const CORBA::Boolean connection_error)
+ throw (Engines::DSC::PortNotDefined,
+ Engines::DSC::PortNotConnected,
+ Engines::DSC::BadPortType);
+ virtual void connect_uses_port(const char* uses_port_name,
+ Ports::Port_ptr provides_port_ref)
+ throw (Engines::DSC::PortNotDefined,
+ Engines::DSC::BadPortType,
+ Engines::DSC::NilPort);
+ virtual void connect_provides_port(const char* provides_port_name)
+ throw (Engines::DSC::PortNotDefined);
+ virtual void disconnect_provides_port(const char* provides_port_name,
+ const Engines::DSC::Message message)
+ throw (Engines::DSC::PortNotDefined,
+ Engines::DSC::PortNotConnected);
+
+ virtual void disconnect_uses_port(const char* uses_port_name,
+ Ports::Port_ptr provides_port_ref,
+ const Engines::DSC::Message message)
+ throw (Engines::DSC::PortNotDefined,
+ Engines::DSC::PortNotConnected,
+ Engines::DSC::BadPortReference);
+
+ virtual Ports::PortProperties_ptr get_port_properties(const char* port_name);
+
+ %extend
+ {
+ //To get the address of the component
+ long ptr()
+ {
+ return (long)self;
+ }
+ }
+};
+
+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
+
+int cp_een(void *component,int dep,float t,int n,char *nom,int nval,int *val);
+int cp_edb(void *component,int dep,double t,int n,char *nom,int nval,double *val);
+
+int cp_len(void *component,int dep,float *INOUT,float *INPUT,int *INOUT,char *nom,int nmax,int *OUTPUT,int *val);
+int cp_ldb(void *component,int dep,double *INOUT,double *INPUT,int *INOUT,char *nom,int nmax,int *OUTPUT,double *val);
+int cp_fin(void *component,int cp_end);
+
--- /dev/null
+import calcium
+import SALOME_ComponentPy
+import SALOME_DriverPy
+import Engines
+
+class PyDSCComponent(SALOME_ComponentPy.SALOME_ComponentPy_i,
+ SALOME_DriverPy.SALOME_DriverPy_i):
+ """
+ A Python SALOME component is implemented by a Python class that has
+ the name of the component and is located in a python module that has the
+ name of the component.
+
+ This class is a base class for Python DSC components.
+
+ You must derive it and implement init_service and those methods
+ that are services of the component.
+ """
+ def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
+ SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa,
+ contID, containerName, instanceName, interfaceName, 0)
+ SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName)
+ # create the DSC proxy
+ self.proxy=calcium.PySupervCompo(orb,poa,contID,instanceName,interfaceName )
+ # Store a reference on naming service in _naming_service attribute
+ self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
+
+ def init_service(self,service):
+ return True
+
+ enums={Engines.DSC.RemovingConnection:calcium.DSC.RemovingConnection,
+ Engines.DSC.AddingConnection:calcium.DSC.AddingConnection,
+ Engines.DSC.ApplicationError:calcium.DSC.ApplicationError,
+ }
+ def get_provides_port(self,name,error):
+ return self.proxy.get_provides_port(name,error)
+
+ def connect_uses_port(self,name,port):
+ self.proxy.connect_uses_port(name,port)
+
+ def connect_provides_port(self,name):
+ self.proxy.connect_provides_port(name)
+
+ def disconnect_provides_port(self,name,message):
+ self.proxy.disconnect_provides_port(name,message._v)
+ #self.proxy.disconnect_provides_port(name,self.enums[message])
+
+ def disconnect_uses_port(self,name,port,message):
+ self.proxy.disconnect_uses_port(name,port,message._v)
+ #self.proxy.disconnect_uses_port(name,port,self.enums[message])
+
+ def get_port_properties(self,name):
+ return self.proxy.get_port_properties(name)
+
data_short_port_provides::data_short_port_provides() {
_val = 0;
+ short_termine = false;
+ short_mutex = new pthread_mutex_t();
+ pthread_mutex_init(short_mutex, NULL);
+ short_condition = new pthread_cond_t();
+ pthread_cond_init(short_condition, NULL);
+ short_termine_cp = true;
+ short_mutex_cp = new pthread_mutex_t();
+ pthread_mutex_init(short_mutex_cp, NULL);
+ short_condition_cp = new pthread_cond_t();
+ pthread_cond_init(short_condition_cp, NULL);
}
-data_short_port_provides::~data_short_port_provides() {}
+data_short_port_provides::~data_short_port_provides() {
+ pthread_mutex_destroy(short_mutex);
+ delete short_mutex;
+ pthread_cond_destroy(short_condition);
+ delete short_condition;
+ pthread_mutex_destroy(short_mutex_cp);
+ delete short_mutex_cp;
+ pthread_cond_destroy(short_condition_cp);
+ delete short_condition_cp;
+}
void
data_short_port_provides::put(CORBA::Short data) {
+ // On attend que le get soit fait
+ pthread_mutex_lock(short_mutex_cp);
+ while (short_termine_cp == false)
+ {
+ pthread_cond_wait(short_condition_cp, short_mutex_cp);
+ }
+ short_termine_cp = false;
+ pthread_mutex_unlock(short_mutex_cp);
+
+ pthread_mutex_lock(short_mutex);
_val = data;
+ short_termine = true;
+ pthread_cond_signal(short_condition);
+ pthread_mutex_unlock(short_mutex);
}
CORBA::Short
data_short_port_provides::get() {
- return _val;
+ CORBA::Short result;
+ pthread_mutex_lock(short_mutex);
+ while (short_termine == false)
+ {
+ pthread_cond_wait(short_condition, short_mutex);
+ }
+ result = _val;
+ short_termine = false;
+ pthread_mutex_unlock(short_mutex);
+
+ // On indique que l'on a copie la valeur
+ pthread_mutex_lock(short_mutex_cp);
+ short_termine_cp = true;
+ pthread_cond_signal(short_condition_cp);
+ pthread_mutex_unlock(short_mutex_cp);
+ return result;
}
Ports::Port_ptr
#include <iostream>
#include "SALOME_Ports.hh"
#include "provides_port.hxx"
+#include <pthread.h>
/*! \class data_short_port_provides
* \brief This class a port that sends a CORBA short with
private :
CORBA::Short _val;
+ pthread_mutex_t * short_mutex;
+ pthread_cond_t * short_condition;
+ bool short_termine;
+ pthread_mutex_t * short_mutex_cp;
+ pthread_cond_t * short_condition_cp;
+ bool short_termine_cp;
+
};
#endif
// Suppose que les valeurs passées en paramètres sont triées par ordre croissant
bool operator()(const T &v1) {
+#ifdef _DEBUG_
std::cout << "AdjacentFunctor: " << _minValue << _maxValue << std::endl;
std::cout << "AdjacentFunctor: " << _min << _max << std::endl;
+#endif
if ( v1 <= _minValue && v1 >= _maxValue)
{
_equal= true;
+#ifdef _DEBUG_
std::cout << "AdjacentFunctor: _equal : " << v1 << std::endl;
+#endif
return true;
}
if ( v1 < _minValue )
{
_min=v1;_minFound=true;
+#ifdef _DEBUG_
std::cout << "AdjacentFunctor: _minFound : " <<_min << std::endl;
+#endif
}
else if ( v1 > _maxValue )
{
_max=v1;_maxFound=true;
+#ifdef _DEBUG_
std::cout << "AdjacentFunctor: _maxFound : " <<_max << std::endl;
+#endif
}
bool isEqual() const { return _equal;}
bool isBounded() const { return _minFound && _maxFound;}
bool getBounds(TNoConst & min, TNoConst & max) const {
+#ifdef _DEBUG_
std::cout << "_minFound : " <<_minFound << ", _maxFound " << _maxFound << std::endl;
+#endif
if (_minFound && _maxFound ) { min=_min; max=_max; return true; }
return false;
}
#include "calcium.h"
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
// Interface C de SalomeCalcium
fflush(stderr); \
fprintf(stderr,"Beginning of CPExx: %s %d %f\n",nomvar,i,t); \
if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL; \
- printf("cp_name : Valeur de nomvar %s\n",nomvar); \
\
InfoType info = ecp_ecriture_##_typeName (component, mode, &t, i, \
nomvar, nbelem, \
CALCIUM_ECR_INTERFACE_C_(edb,double,double,double,);
CALCIUM_ECR_INTERFACE_C_(elo,float,bool,bool,);
CALCIUM_ECR_INTERFACE_C_(ecp,float,float,cplx,);
+
--- /dev/null
+#include "Calcium.hxx"
+#include <CalciumInterface.hxx>
+#include <calcium.h>
+#include <iostream>
+#include <string>
+#include <exception>
+
+//#define _DEBUG_
+
+PySupervCompo::PySupervCompo( CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ Engines::Container_ptr contain,
+ const char *instanceName,
+ const char *interfaceName,
+ bool notif) :
+ Superv_Component_i(orb, poa,poa->reference_to_id(contain), instanceName, interfaceName)
+{
+}
+
+PySupervCompo::~PySupervCompo()
+{
+}
+
+
+extern "C"
+{
+ void cp_exit(int err)
+ {
+ throw CalciumException(err,LOC("Abort coupling"));
+ }
+
+ void setDependency(provides_port * port,char* type,CalciumTypes::DependencyType depend)
+ {
+ if(std::string(type)=="CALCIUM_real")
+ {
+ dynamic_cast<calcium_real_port_provides *>(port)->setDependencyType(depend);
+ }
+ else if(std::string(type)=="CALCIUM_double")
+ {
+ dynamic_cast<calcium_double_port_provides *>(port)->setDependencyType(depend);
+ }
+ else if(std::string(type)=="CALCIUM_integer")
+ {
+ dynamic_cast<calcium_integer_port_provides *>(port)->setDependencyType(depend);
+ }
+ else
+ {
+ std::cerr << "unknown type:" << std::endl;
+ }
+ }
+
+ void create_calcium_port(Superv_Component_i* compo,char* name,char* type,char *mode,char* depend)
+ {
+#ifdef _DEBUG_
+ std::cerr << "create_calcium_port: " << name << " " << type << " " << mode << " " << depend << std::endl;
+#endif
+
+ if(std::string(mode) == "IN")
+ {
+ provides_port * port ;
+ //provides port
+ try
+ {
+ port = compo->create_provides_data_port(type);
+ compo->add_port(port, name);
+ if(std::string(depend) == "I")
+ setDependency(port,type,CalciumTypes::ITERATION_DEPENDENCY);
+ else if(std::string(depend) == "T")
+ setDependency(port,type,CalciumTypes::TIME_DEPENDENCY);
+ else
+ {
+ std::cerr << "create_calcium_port:unknown dependency: " << depend << std::endl;
+ }
+ }
+ catch(const Superv_Component_i::PortAlreadyDefined& ex)
+ {
+ //Port already defined : we use the old one
+ delete port;
+ std::cerr << "create_calcium_port: " << ex.what() << std::endl;
+ }
+ catch ( ... )
+ {
+ std::cerr << "create_calcium_port: unknown exception" << std::endl;
+ }
+ }
+ else if(std::string(mode) == "OUT")
+ {
+ uses_port * uport ;
+ try
+ {
+ uport = compo->create_uses_data_port(type);
+ compo->add_port(uport, name);
+ }
+ catch(const Superv_Component_i::PortAlreadyDefined& ex)
+ {
+ //Port already defined : we use the old one
+ delete uport;
+ std::cerr << "create_calcium_port: " << ex.what() << std::endl;
+ }
+ catch ( ... )
+ {
+ std::cerr << "create_calcium_port: unknown exception" << std::endl;
+ }
+ }
+ else
+ {
+ //Unknown mode
+ std::cerr << "create_calcium_port:Unknown mode: " << mode << std::endl;
+ }
+ }
+
+}
+
+
--- /dev/null
+#include "Superv_Component_i.hxx"
+
+class PySupervCompo:public Superv_Component_i
+{
+ public:
+ PySupervCompo(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ Engines::Container_ptr contain,
+ const char *instanceName,
+ const char *interfaceName,
+ bool notif = false);
+ virtual ~PySupervCompo();
+ CORBA::Boolean init_service(const char * service_name){return true;};
+};
+
+
+extern "C" void create_calcium_port(Superv_Component_i* compo,char* name,char* type,char *mode,char* depend);
MapIterator it2=it1; ++it2;
size_t dataSize1 = DataManipulator::size(it1->second);
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Taille de donnée dataId1 : " << dataSize1 << std::endl;
+#endif
// Gérer dans calcium la limite de la taille du buffer donnée par
// l'utilisateur.
size_t dataSize2 = DataManipulator::size(it2->second);
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Taille de donnée dataId2 : " << dataSize2 << std::endl;
+#endif
size_t dataSize = std::min< size_t >( dataSize1, dataSize2 );
DataId dataId2 = it2->first;
DataId dataId1 = it1->first;
TimeType t2 = dataId2.first;
TimeType t1 = dataId1.first;
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de t1 : " << t1 << std::endl;
std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de t2 : " << t2 << std::endl;
+#endif
TimeType t = dataId.first;
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de t : " << t << std::endl;
+#endif
TimeType timeDiff = t2-t1;
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de timeDiff : " << timeDiff << std::endl;
+#endif
TimeType coeff = (t2-t)/timeDiff;
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Valeur de coeff : " << coeff << std::endl;
+#endif
InnerType const * const InIt1 = DataManipulator::getPointer(it1->second);
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Données à t1 : " << std::endl;
std::copy(InIt1,InIt1+dataSize1,std::ostream_iterator<InnerType>(std::cout," "));
std::cout << std::endl;
+#endif
InnerType const * const InIt2 = DataManipulator::getPointer(it2->second);
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Données à t2 : " << std::endl;
std::copy(InIt2,InIt2+dataSize2,std::ostream_iterator<InnerType>(std::cout," "));
std::cout << std::endl;
+#endif
Type dataOut = DataManipulator::create(dataSize);
InnerType * const OutIt = DataManipulator::getPointer(dataOut);
// }
}
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : Données calculées à t : " << std::endl;
std::copy(OutIt,OutIt+dataSize,std::ostream_iterator<InnerType>(std::cout," "));
std::cout << std::endl;
+#endif
data = dataOut;
}
AdjacentFunctor< key_type > af(expectedDataId);
if ( _dependencyType == CalciumTypes::TIME_DEPENDENCY )
{
+#ifdef _DEBUG_
std::cout << "-------- time expected : " << expectedDataId.first << std::endl;
std::cout << "-------- time expected corrected : " << expectedDataId.first*(1.0-_deltaT) << std::endl;
+#endif
af.setMaxValue(key_type(expectedDataId.first*(1.0-_deltaT),0));
}
isBounded = false;
typename AssocContainer::iterator current = prev;
while ( (current != storedDatas.end()) && !af(current->first) )
{
+#ifdef _DEBUG_
std::cout << "------- stored time : " << current->first << std::endl;
+#endif
// if ( af(current->first) ) break;
prev = current++;
}
else
wDataIt1 = storedDatas.end();
+#ifdef _DEBUG_
std::cout << "-------- isDataIdConvenient : isEqual : " << isEqual << " , isBounded " << isBounded << std::endl;
+#endif
return isEqual || isBounded;
}
typedef typename Container::value_type value_type;
typedef typename Container::iterator iterator;
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::eraseDataId, storedDatasSize : " << storedDatas.size() << std::endl;
+#endif
if ( _couplingPolicy._storageLevel == CalciumTypes::UNLIMITED_STORAGE_LEVEL ) return;
if (s > 0 ) {
size_t dist=distance(storedDatas.begin(),wDataIt1);
for (int i=0; i<s; ++i) {
- DataManipulator::delete_data((*storedDatas.begin()).second);
- storedDatas.erase(storedDatas.begin());
+ //no bug if removed : DataManipulator::delete_data((*storedDatas.begin()).second);
+ DataManipulator::delete_data((*storedDatas.begin()).second);
+ storedDatas.erase(storedDatas.begin());
}
// Si l'itérateur pointait sur une valeur que l'on vient de supprimer
if (dist < s ) {
" vient d'entraîner la suppression de la donnée à renvoyer")));
}
}
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::eraseDataId, new storedDatasSize : " << storedDatas.size() << std::endl;
+#endif
return;
}
typedef typename Container::iterator iterator;
// Pas de traitement particulier a effectuer
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK1 ("<< _couplingPolicy._disconnectDirective<<") --------" << std::endl;
+#endif
if ( (_couplingPolicy._disconnectDirective) == (CalciumTypes::UNDEFINED_DIRECTIVE) ) return false;
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK2 --------" << std::endl;
+#endif
// TODO : Ds GenericPort::next il faut convertir en CPSTOPSEQ
if ( _couplingPolicy._disconnectDirective == CalciumTypes::CP_ARRET )
throw(CalciumException(CalciumTypes::CPINARRET,LOC(OSS()<< "La directive CP_ARRET"
<< " provoque l'interruption de toute lecture de données")));
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK3 --------" << std::endl;
+#endif
// S'il n'y a plus de données indique que l'on a pas pu effectuer de traitement
// qu'en mode itératif il ne soit pas plus grand que le plus grand DataId stocké auquel
// cas on doit renvoyer une expection car on n'est plus connecté et on ne pourra jamais
// fournir de données pour ce dataId.
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK4 " << expectedDataId <<" --------" << std::endl;
+#endif
// >= expectedDataId
iterator it1 = storedDatas.lower_bound(expectedDataId);
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK5 " << std::endl;
for (iterator it=storedDatas.begin();it!=storedDatas.end();++it)
std::cout <<" "<<(*it).first ;
std::cout <<std::endl;
+#endif
// TODO : Il faut en fait renvoyer le plus proche cf IT ou DT
if (it1 == storedDatas.end())
throw(CalciumException(CalciumTypes::CPNTNULL,LOC(OSS()<< "La directive CP_CONT"
<< " est active mais le dataId demandé est inférieur ou égal au dernier reçu.")));
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor MARK6 " << std::endl;
+#endif
wDataIt1 = storedDatas.end();
--wDataIt1;
+#ifdef _DEBUG_
std::cout << "-------- CalciumCouplingPolicy::DisconnectProcessor, CP_CONT : " << (*wDataIt1).first << std::endl;
+#endif
return true;
}
#include <stdio.h>
+//#define _DEBUG_
// Déplacer cette information dans CorbaTypeManipulator
// Gérer en même temps la recopie profonde.
// calcium_uses_port* myCalciumUsesPort=
// dynamic_cast<calcium_uses_port*>(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 "
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
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 <nul>"));
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));
}
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 ) {
nRead = corbaDataSize;
// Si les types T et InnerType sont différents, il faudra effectuer tout de même une recopie
if (!IsSameType<T1,InnerType>::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<T1,InnerType>::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
// 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<false>::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<T1>(std::cout," "));
std::cout << "Ptr :" << data << std::endl;
std::cout << "-------- CalciumInterface(ecp_lecture) MARK 13 ------------------" << std::endl;
+#endif
return;
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 <nul>"));
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));
}
LOC(OSS()<<"Le buffer a envoyer est de taille nulle "));
+#ifdef _DEBUG_
std::cout << "-------- CalciumInterface(ecriture) MARK 7 ------------------" << std::endl;
+#endif
CorbaDataType corbaData;
port->put(*corbaData,t, -1);
//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 ) {
port->put(*corbaData,-1, i);
+#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;
+#endif
// if ( !IsSameType<T1,InnerType>::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;
}
CalciumInterface::ecp_fin( *_component,
provideLastGivenValue);
} catch ( const CalciumException & ex) { //tester l'arrêt par exception
+#ifdef _DEBUG_
std::cerr << ex.what() << std::endl;
+#endif
return ex.getInfo();
}
return CalciumTypes::CPOK;
};
+#ifdef _DEBUG_
+#define DEBTRACE(msg) {std::cerr<<std::flush<<__FILE__<<" ["<<__LINE__<<"] : "<<msg<<std::endl<<std::flush;}
+#else
+#define DEBTRACE(msg)
+#endif
+
#define CALCIUM_C2CPP_INTERFACE_(_name,_type,_qual) \
extern "C" CalciumTypes::InfoType ecp_lecture_##_name (void * component, int dependencyType, \
static_cast<CalciumTypes::DependencyType>(dependencyType); \
\
if ( IsSameType< _name , cplx >::value ) _bufferLength*=2; \
- std::cout << "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" << std::endl; \
+ DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" ) \
try { \
CalciumInterface::ecp_lecture< _type, _name >( *_component, \
_dependencyType, \
nomvar, \
_bufferLength, _nRead, *data); \
} catch ( const CalciumException & ex) { \
- std::cout << "-------- CalciumInterface(lecture Inter Part) MARK 1b ------------------" << std::endl; \
- std::cerr << ex.what() << std::endl; \
- std::cout << "-------- CalciumInterface(lecture Inter Part) MARK 1ter ------------------" << std::endl; \
+ DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1b ------------------" ) \
+ DEBTRACE( ex.what() ) \
+ DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1ter ------------------" ) \
return ex.getInfo(); \
} \
if ( IsSameType< _name , cplx >::value ) { *nRead=_nRead/2; \
- std::cout << "-------- CalciumInterface(lecture Inter Part) IsSameType cplx -------------" << std::endl; \
- std::cout << "-------- CalciumInterface(lecture Inter Part) _nRead : " << _nRead << std::endl; \
- std::cout << "-------- CalciumInterface(lecture Inter Part) *nRead : " << *nRead << std::endl; \
+ DEBTRACE( "-------- CalciumInterface(lecture Inter Part) IsSameType cplx -------------" ) \
+ DEBTRACE( "-------- CalciumInterface(lecture Inter Part) _nRead : " << _nRead ) \
+ DEBTRACE( "-------- CalciumInterface(lecture Inter Part) *nRead : " << *nRead ) \
} else *nRead = _nRead; \
if (_dependencyType == CalciumTypes::CP_SEQUENTIEL ) \
*ti=(CalTimeType< _type _qual >::TimeType)(_ti); \
- std::cout << "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data << std::endl; \
+ 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]); \
- std::cout << "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data << std::endl; \
+ */ \
+ DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data ) \
return CalciumTypes::CPOK; \
}; \
extern "C" void ecp_lecture_##_name##_free ( _type _qual * data) { \
double _t=*t; \
size_t _bufferLength=bufferLength; \
if ( IsSameType< _name , cplx >::value ) _bufferLength=_bufferLength*2; \
- std::cout << "-------- CalciumInterface(ecriture Inter Part) MARK 1 ------------------" << std::endl; \
+ DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 1 ------------------" ) \
try { \
- printf("-------- CalciumInterface(ecriture Inter Part), cp_name : Nom de la var. de type %s : %s\n",#_type,nomvar); \
+ /*printf("-------- CalciumInterface(ecriture Inter Part), cp_name : Nom de la var. de type %s : %s\n",#_type,nomvar);*/ \
std::string essai(nomvar); \
- std::cout << "----------->-" << nomvar << std::endl; \
+ DEBTRACE( "----------->-" << nomvar ) \
CalciumInterface::ecp_ecriture< _type, _name >( *_component, \
static_cast<CalciumTypes::DependencyType>(dependencyType), \
_t,i,nomvar,_bufferLength,*data); \
std::cerr << ex.what() << std::endl; \
return ex.getInfo(); \
} \
- std::cout << "-------- CalciumInterface(ecriture Inter Part), Valeur de data : " << std::endl; \
- std::cout << "-------- CalciumInterface(ecriture Inter Part), Ptr(1) :" << data << std::endl; \
+ 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]); \
- std::cout << "-------- CalciumInterface(ecriture Inter Part), Ptr(2) :" << data << std::endl; \
+ */ \
+ DEBTRACE( "-------- CalciumInterface(ecriture Inter Part), Ptr(2) :" << data ) \
return CalciumTypes::CPOK; \
}; \
table[CalciumTypes::UNDEFINED_DEPENDENCY ] = Ports::Calcium_Ports::UNDEFINED_DEPENDENCY ;
+#ifdef _DEBUG_
std::cout << "CORBA_DEPENDENCY_TYPE() : table["<<CalciumTypes::TIME_DEPENDENCY<<"] : "<<
table[CalciumTypes::TIME_DEPENDENCY] << std::endl;
std::cout << "CORBA_DEPENDENCY_TYPE() : table["<<CalciumTypes::ITERATION_DEPENDENCY<<"] : "<<
table[CalciumTypes::ITERATION_DEPENDENCY] << std::endl;
std::cout << "CORBA_DEPENDENCY_TYPE() : table["<<CalciumTypes::UNDEFINED_DEPENDENCY<<"] : "<<
table[CalciumTypes::UNDEFINED_DEPENDENCY] << std::endl;
+#endif
}
table = (map<CalciumTypes::DependencyType,
Ports::Calcium_Ports::DependencyType >& ) *this ;
+#ifdef _DEBUG_
std::cout << "CORBA_DEPENDENCY_TYPE() : ::operator["<<c<<"]: " << table[c] << std::endl;
+#endif
assert( table.find( (CalciumTypes::DependencyType)c ) != table.end() ) ;
return table[ (CalciumTypes::DependencyType)c ] ;
typedef typename PortType::DataManipulator DataManipulator;
typedef typename DataManipulator::InnerType InnerType;
+#ifdef _DEBUG_
std::cerr << "-------- Copy2CorbaSpace<true> MARK 1 ------------------" << std::endl;
+#endif
// Crée le type corba à partir du data sans lui en donner la propriété
corbaData = DataManipulator::create(nRead,&data,false);
+#ifdef _DEBUG_
std::cerr << "-------- Copy2CorbaSpace<true> MARK 2 --(dataPtr : "
<< DataManipulator::getPointer(corbaData,false)<<")----------------" << std::endl;
+#endif
}
};
corbaData = DataManipulator::create(nRead);
InnerType * dataPtr = DataManipulator::getPointer(corbaData,false);
+#ifdef _DEBUG_
std::cerr << "-------- Copy2CorbaSpace<false> MARK 1 --(dataPtr : " <<
dataPtr<<")----------------" << std::endl;
+#endif
std::copy(&data,&data+nRead,dataPtr);
+#ifdef _DEBUG_
std::cerr << "-------- Copy2CorbaSpace<false> MARK 2 --(nRead: "<<nRead<<")-------------" << std::endl;
std::cerr << "-------- Copy2CorbaSpace<false> MARK 3 : " ;
for (int i=0; i<nRead; ++i)
std::cerr << (*corbaData)[i] << " ";
std::cout << std::endl;
+#endif
}
};
// 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<false> MARK 1 --(dataPtr : " <<dataPtr<<")----------------" << std::endl;
+#endif
std::copy(dataPtr,dataPtr+nRead,data);
+#ifdef _DEBUG_
std::cerr << "-------- Copy2UserSpace<false> MARK 2 --(nRead: "<<nRead<<")-------------" << std::endl;
std::cerr << "-------- Copy2UserSpace<false> MARK 3 --(data : " <<data<<") :";
std::copy(data,data+nRead,std::ostream_iterator<T1>(std::cout," "));
std::cout << std::endl;
+#endif
}
};
table[Ports::Calcium_Ports::UNDEFINED_DEPENDENCY ] = CalciumTypes::UNDEFINED_DEPENDENCY ;
+#ifdef _DEBUG_
std::cout << "DEPENDENCY_TYPE() : table["<<Ports::Calcium_Ports::TIME_DEPENDENCY<<"] : "<<
table[Ports::Calcium_Ports::TIME_DEPENDENCY] << std::endl;
std::cout << "DEPENDENCY_TYPE() : table["<<Ports::Calcium_Ports::ITERATION_DEPENDENCY<<"] : "<<
table[Ports::Calcium_Ports::ITERATION_DEPENDENCY] << std::endl;
std::cout << "DEPENDENCY_TYPE() : table["<<Ports::Calcium_Ports::UNDEFINED_DEPENDENCY<<"] : "<<
table[Ports::Calcium_Ports::UNDEFINED_DEPENDENCY] << std::endl;
+#endif
}
CalciumTypes::DependencyType> &table = (map<Ports::Calcium_Ports::DependencyType,
CalciumTypes::DependencyType>&)*this ;
+#ifdef _DEBUG_
std::cout << "DEPENDENCY_TYPE() : ::operator["<<c<<"]: " << table[c] << std::endl;
+#endif
assert( table.find( (Ports::Calcium_Ports::DependencyType)c ) != table.end() ) ;
return table[ (Ports::Calcium_Ports::DependencyType)c ] ;
Copy2CorbaSpace.hxx \
CalciumPortTraits.hxx \
calcium.h \
+ Calcium.hxx \
calciumP.h \
version.h \
calcium.hf
# This local variable defines the list of CPPFLAGS common to all target in this package.
COMMON_CPPFLAGS= -I$(top_srcdir)/src/DSC/DSC_User \
-I$(top_srcdir)/src/DSC/DSC_User/Datastream \
+ -I$(top_srcdir)/src/DSC/DSC_User/Datastream/Palm \
+ -I$(top_srcdir)/src/DSC/DSC_User/Basic \
-I$(top_srcdir)/src/DSC/DSC_Basic \
-I$(top_srcdir)/src/SALOMELocalTrace \
-I$(top_srcdir)/src/Basics \
-I$(top_srcdir)/src/Utils \
+ -I$(top_srcdir)/src/Container \
+ -I$(top_srcdir)/src/Notification \
-I$(top_builddir)/salome_adm/unix \
-I$(top_builddir)/idl \
@CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @BOOST_CPPFLAGS@
CorbaTypes2CalciumTypes.cxx \
CalciumTypes2CorbaTypes.cxx \
CalciumProvidesPort.cxx \
+ Calcium.cxx \
calcium_destructors_port_uses.cxx
libSalomeCalcium_la_CXXFLAGS = $(COMMON_CPPFLAGS)
AM_CFLAGS = -fexceptions
lib_LTLIBRARIES = libCalciumC.la
-libCalciumC_la_SOURCES = Calcium.c
+libCalciumC_la_SOURCES = Calcium.c Calcium.cxx calciumf.c
+libCalciumC_la_CXXFLAGS = $(COMMON_CPPFLAGS)
#
# ===============================================================
#
noinst_PROGRAMS = test_DataIdContainer
## testInterpolation
-
-testInterpolation_SOURCES = testInterpolation.cxx
-testInterpolation_CXXFLAGS = -I/usr/include
+## testInterpolation_SOURCES = testInterpolation.cxx
+## testInterpolation_CXXFLAGS = -I/usr/include
test_DataIdContainer_SOURCES = test_DataIdContainer.cxx
-
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
--- /dev/null
+#include <string.h>
+#include <stdlib.h>
+#include <fortoc.h>
+#include <calcium.h>
+#include <stdio.h>
+
+static void* COMPO=0;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static void fstrtocstr(char *cstr, char *fstr,int fstr_len)
+{
+ int i,iend;
+ for (iend = fstr_len-1; iend >= 0; iend--)
+ if (fstr[iend] != ' ') break;
+ for (i = 0; i <= iend; i++)
+ cstr[i] = fstr[i];
+ cstr[i] = '\0';
+}
+
+static void cstrtofstr(char *cstr, char *fstr,int fstr_len)
+{
+ int i, len;
+ len = strlen(cstr);
+ if (len > fstr_len) len = fstr_len;
+ for (i = 0; i < len; i++)
+ fstr[i] = cstr[i];
+ while (i < fstr_len)
+ fstr[i++] = ' ';
+}
+
+static char * fstr1(char *nom,int nnom)
+{
+ char * cnom=(char*)malloc((nnom+1)*sizeof(char));
+ fstrtocstr(cnom,nom,nnom);
+ return cnom;
+}
+
+static char * free_str1(char *nom)
+{
+ free(nom);
+}
+
+void F_FUNC(cpcd,CPCD)(long *compo,STR_PSTR(nom),int *info STR_PLEN(nom))
+{
+ /* nom is OUT argument */
+ cp_cd((void *)*compo,STR_PTR(nom));
+ /* replace in place ??? */
+ cstrtofstr(STR_PTR(nom),STR_PTR(nom),STR_LEN(nom));
+}
+
+void F_FUNC(cplen,CPLEN)(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,"CPLEN: %s %f %f\n",cnom,*ti,*tf);
+ *err=cp_len((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
+ fprintf(stderr,"End of CPLEN: %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))
+{
+ char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
+ fprintf(stderr,"CPLDB: %s %f %f \n",cnom, *ti,*tf);
+ *err=cp_ldb((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
+ fprintf(stderr,"End of CPLDB: %s %f %f \n",cnom,*ti,*tf);
+ free_str1(cnom);
+}
+
+void F_FUNC(cplre,CPLRE)(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,"CPLRE: %s %f %f \n",cnom, *ti,*tf);
+ *err=cp_lre((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,tab);
+ fprintf(stderr,"End of CPLRE: %s %f %f \n",cnom,*ti,*tf);
+ 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));
+ fprintf(stderr,"CPEDB: %s %f \n",cnom, *ti);
+ *err=cp_edb((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
+ fprintf(stderr,"End of CPEDB: %s %f \n",cnom, *ti);
+ free_str1(cnom);
+}
+
+void F_FUNC(cpere,CPERE)(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,"CPERE: %s %f \n",cnom, *ti);
+ *err=cp_ere((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
+ fprintf(stderr,"End of CPERE: %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));
+ fprintf(stderr,"CPEEN: %s %f %d\n",cnom, *ti,*iter);
+ *err=cp_een((void *)*compo,*dep,*ti,*iter,cnom,*n,tab);
+ fprintf(stderr,"End of CPEEN: %s %f \n",cnom,*ti);
+ free_str1(cnom);
+}
+
+void F_FUNC(cpfin,CPFIN)(long *compo,int *dep,int *err)
+{
+ fprintf(stderr,"CPFIN: \n");
+ *err=cp_fin((void *)*compo,*dep);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
--- /dev/null
+
+#ifndef FORTRAN_H
+#define FORTRAN_H
+
+/* Operateur de concatenation */
+#define _(A,B) A##B
+
+#ifdef __linux
+#define F_FUNC(lname,uname) _(lname,_) /* Fortran function name */
+#define F_CALL(lname,uname) _(lname,_) /* Fortran function call */
+#define STR_PSTR(str) char *str /* fortran string arg pointer */
+#define STR_PLEN(str) , int _(Len,str) /* fortran string arg length */
+#define STR_PTR(str) str /* fortran string pointer */
+#define STR_LEN(str) _(Len,str) /* fortran string length */
+
+
+#endif
+
+#endif
+
// ATTENTION TESTER p184 si le pointeur est null
// ATTENTION TESTER Si le flag release si la sequence contient des chaines
// ou des object refs
+#ifdef _DEBUG_
std::cout << "----seq_u_manipulation::get_data(..)-- MARK 1 ------------------" << std::endl;
+#endif
InnerType * p_data = const_cast<seq_T &>(data).get_buffer(true);
+#ifdef _DEBUG_
std::cout << "----seq_u_manipulation::get_data(..)-- MARK 2 ------"<< p_data <<"------------" << std::endl;
+#endif
// 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
template < typename DataManipulator, typename COUPLING_POLICY> void
GenericPort<DataManipulator, COUPLING_POLICY>::wakeupWaiting()
{
+#ifdef _DEBUG_
std::cout << "-------- wakeupWaiting ------------------" << std::endl;
+#endif
storedDatas_mutex.lock();
if (waitingForAnyDataId || waitingForConvenientDataId) {
+#ifdef _DEBUG_
std::cout << "-------- wakeupWaiting:signal --------" << std::endl;
std::cout << std::flush;
+#endif
cond_instance.signal();
}
storedDatas_mutex.unlock();
fflush(stdout);
fflush(stderr);
try {
+#ifdef _DEBUG_
// Affichage des donnees pour DEBUGging
cerr << "parametres emis: " << time << ", " << tag << endl;
DataManipulator::dump(dataParam);
+#endif
// L'intérêt des paramètres time et tag pour ce port est décidé dans la politique de couplage
// Il est possible de filtrer en prenant en compte uniquement un paramètre time/tag ou les deux
bool expectedDataReceived = false;
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 1 ------------------" << std::endl;
+#endif
if ( dataIds.empty() ) return;
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 1bis ------------------" << std::endl;
+#endif
// Recupere les donnees venant de l'ORB et relâche les structures CORBA
// qui n'auraient plus cours en sortie de méthode put
int nbOfIter = 0;
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 2 ------ "<< (dataIdIt == dataIds.end()) << "------------" << std::endl;
std::cout << "-------- Put : MARK 2bis "<< (*dataIdIt) <<"------------------" << std::endl;
+#endif
storedDatas_mutex.lock();
for (;dataIdIt != dataIds.end();++dataIdIt) {
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 3 ------------------" << std::endl;
+#endif
// Duplique l'instance de donnée pour les autres dataIds
if (nbOfIter > 0) data = DataManipulator::clone(data);
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 3bis -----"<< dataIdIt.operator*() <<"------------" << std::endl;
+#endif
DataId currentDataId=*dataIdIt;
+#ifdef _DEBUG_
std::cerr << "processing dataId : "<< currentDataId << std::endl;
std::cout << "-------- Put : MARK 4 ------------------" << std::endl;
+#endif
// Ajoute l'instance de la donnee a sa place dans la table de données
// ou remplace une instance précédente si elle existe
// <=> premier emplacement où l'on pourrait insérer notre DataId
// <=> en général équivaux à (*wDataIt).first >= currentDataId
typename DataTable::iterator wDataIt = storedDatas.lower_bound(currentDataId);
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 5 ------------------" << std::endl;
+#endif
// On n'a pas trouvé de dataId supérieur au notre ou
// on a trouvé une clé > à cet Id
if (wDataIt == storedDatas.end() || storedDatas.key_comp()(currentDataId,(*wDataIt).first) ) {
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 6 ------------------" << std::endl;
+#endif
// Ajoute la donnee dans la table
wDataIt = storedDatas.insert(wDataIt, make_pair (currentDataId, data));
} else {
// Si on n'est pas en fin de liste et qu'il n'y a pas de relation d'ordre strict
// entre notre dataId et le DataId pointé c'est qu'ils sont identiques
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 7 ------------------" << std::endl;
+#endif
// Les données sont remplacées par les nouvelles valeurs
// lorsque que le dataId existe déjà
DataType old_data = (*wDataIt).second;
DataManipulator::delete_data (old_data);
}
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 8 ------------------" << std::endl;
+#endif
// Compte le nombre de dataIds à traiter
++nbOfIter;
+#ifdef _DEBUG_
std::cout << "-------- Put : waitingForConvenientDataId : " << waitingForConvenientDataId <<"---" << std::endl;
std::cout << "-------- Put : waitingForAnyDataId : " << waitingForAnyDataId <<"---" << std::endl;
std::cout << "-------- Put : currentDataId : " << currentDataId <<"---" << std::endl;
std::cout << "-------- Put : expectedDataId : " << expectedDataId <<"---" << std::endl;
std::cout << "-------- Put : MARK 9 ------------------" << std::endl;
+#endif
// A simplifier mais :
// - pas possible de mettre des arguments optionnels à cause
( waitingForConvenientDataId &&
isDataIdConveniant(storedDatas, expectedDataId, dummy1, dummy2, dummy3) )
) {
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 10 ------------------" << std::endl;
+#endif
//Doit pouvoir réveiller le get ici (a vérifier)
expectedDataReceived = true;
}
}
if (expectedDataReceived) {
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 11 ------------------" << std::endl;
+#endif
// si waitingForAnyDataId était positionné, c'est forcément lui qui a activer
// expectedDataReceived à true
if (waitingForAnyDataId)
// Pb2 : également si deux attentes de DataIds même différents car on n'en stocke qu'un !
// Conclusion : Pour l'instant on ne gère pas un service multithreadé qui effectue
// des lectures simultanées sur le même port !
+#ifdef _DEBUG_
std::cout << "-------- Put : new datas available ------------------" << std::endl;
+#endif
fflush(stdout);fflush(stderr);
cond_instance.signal();
}
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 12 ------------------" << std::endl;
+#endif
// Deverouille l'acces a la table : On peut remonter l'appel au dessus de expected...
storedDatas_mutex.unlock();
+#ifdef _DEBUG_
std::cout << "-------- Put : MARK 13 ------------------" << std::endl;
+#endif
fflush(stdout);
fflush(stderr);
catch ( const SALOME_Exception & ex ) {
// On évite de laisser un mutex
storedDatas_mutex.unlock();
- std::cerr << ex;
THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
}
bool isEqual, isBounded;
typedef typename DataManipulator::InnerType InnerType;
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 1 ------------------" << std::endl;
+#endif
expectedDataId = DataId(time,tag);
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 2 ------------------" << std::endl;
+#endif
typename DataTable::iterator wDataIt1;
// - l'itérateur wDataIt1 est tel que wDataIt1->first < wdataId < (wDataIt1+1)->first
// Méthode provenant de la COUPLING_POLICY
isDataIdConveniant(storedDatas,expectedDataId,isEqual,isBounded,wDataIt1);
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 3 ------------------" << std::endl;
+#endif
// L'ordre des différents tests est important
if ( isEqual ) {
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 4 ------------------" << std::endl;
+#endif
// La propriété de la données N'EST PAS transmise à l'utilisateur en mode CALCIUM.
// Si l'utilisateur supprime la donnée, storedDataIds devient incohérent
// C'est EraseDataId qui choisi ou non de supprimer la donnée
// Du coup interaction potentielle entre le 0 copy et gestion de l'historique
dataToTransmit = (*wDataIt1).second;
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 5 ------------------" << std::endl;
std::cout << "-------- Get : Données trouvées à t : " << std::endl;
typename DataManipulator::InnerType const * const InIt1 = DataManipulator::getPointer(dataToTransmit);
std::copy(InIt1, InIt1 + N,
std::ostream_iterator< InnerType > (std::cout," "));
std::cout << std::endl;
+#endif
// Décide de la suppression de certaines instances de données
// La donnée contenu dans la structure CORBA et son dataId sont désallouées
// Méthode provenant de la COUPLING_POLICY
typename COUPLING_POLICY::template EraseDataIdProcessor<DataManipulator> processEraseDataId(*this);
processEraseDataId.apply(storedDatas,wDataIt1);
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 6 ------------------" << std::endl;
+#endif
break;
}
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 7 ------------------" << std::endl;
+#endif
//if ( isBounded() && COUPLING_POLICY::template needToProcessBoundedDataId() ) {
// Le DataId demandé n'est pas trouvé mais est encadré ET la politique de couplage
// 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<DataManipulator> processBoundedDataId(*this);
//si static BDIP::apply(dataToTransmit,expectedDataId,wDataIt1);
// A déplacer en paramètre de la méthode précédente ?
storedDatas[expectedDataId]=dataToTransmit;
+#ifdef _DEBUG_
std::cout << "-------- Get : Données calculées à t : " << std::endl;
typename DataManipulator::InnerType const * const InIt1 = DataManipulator::getPointer(dataToTransmit);
size_t N = DataManipulator::size(dataToTransmit);
std::ostream_iterator< InnerType > (std::cout," "));
std::cout << std::endl;
std::cout << "-------- Get : MARK 9 ------------------" << std::endl;
+#endif
typename COUPLING_POLICY::template EraseDataIdProcessor<DataManipulator> processEraseDataId(*this);
processEraseDataId.apply(storedDatas,wDataIt1);
// Réception bloquante sur le dataId demandé
// Si l'instance de donnée n'est pas trouvee
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 10 ------------------" << std::endl;
+#endif
//Positionné à faux dans la méthode put
waitingForConvenientDataId = true;
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 11 ------------------" << std::endl;
// Ici on attend que la méthode put recoive la donnée
std::cout << "-------- Get : waiting datas ------------------" << std::endl;
+#endif
fflush(stdout);fflush(stderr);
cond_instance.wait();
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 12 ------------------" << std::endl;
+#endif
}
} catch (...) {
// Deverouille l'acces a la table
storedDatas_mutex.unlock();
+#ifdef _DEBUG_
std::cout << "-------- Get : MARK 13 ------------------" << std::endl;
+#endif
// La propriété de la données N'EST PAS transmise à l'utilisateur en mode CALCIUM
// Si l'utilisateur supprime la donnée, storedDataIds devient incohérent
try {
storedDatas_mutex.lock();// Gérer les Exceptions ds le corps de la méthode
+#ifdef _DEBUG_
std::cout << "-------- Next : MARK 1 ---lastDataIdSet ("<<lastDataIdSet<<")---------------" << std::endl;
+#endif
typename DataTable::iterator wDataIt1;
wDataIt1 = storedDatas.end();
waitingForAnyDataId = false; break;
}
+#ifdef _DEBUG_
std::cout << "-------- Next : MARK 2 ------------------" << std::endl;
+#endif
//Positionné à faux dans la méthode put
waitingForAnyDataId = true;
+#ifdef _DEBUG_
std::cout << "-------- Next : MARK 3 ------------------" << std::endl;
// Ici on attend que la méthode put recoive la donnée
std::cout << "-------- Next : waiting datas ------------------" << std::endl;
+#endif
fflush(stdout);fflush(stderr);
cond_instance.wait();
if (lastDataIdSet) {
+#ifdef _DEBUG_
std::cout << "-------- Next : MARK 4 ------------------" << std::endl;
+#endif
wDataIt1 = storedDatas.upper_bound(lastDataId);
} else {
+#ifdef _DEBUG_
std::cout << "-------- Next : MARK 5 ------------------" << std::endl;
+#endif
lastDataIdSet = true;
wDataIt1 = storedDatas.begin();
}
}
+#ifdef _DEBUG_
std::cout << "-------- Next : MARK 6 ------------------" << std::endl;
+#endif
t = getTime( (*wDataIt1).first );
tag = getTag ( (*wDataIt1).first );
dataToTransmit = (*wDataIt1).second;
+#ifdef _DEBUG_
std::cout << "-------- Next : MARK 7 ------------------" << std::endl;
+#endif
lastDataId = (*wDataIt1).first;
typename COUPLING_POLICY::template EraseDataIdProcessor<DataManipulator> processEraseDataId(*this);
processEraseDataId.apply(storedDatas, wDataIt1);
+#ifdef _DEBUG_
std::cout << "-------- Next : MARK 8 ------------------" << std::endl;
+#endif
} catch (...) {
+#ifdef _DEBUG_
std::cout << "-------- Next : MARK 8bis ------------------" << std::endl;
+#endif
waitingForAnyDataId = false;
storedDatas_mutex.unlock();
throw;
}
storedDatas_mutex.unlock();
+#ifdef _DEBUG_
std::cout << "-------- Next : MARK 9 ------------------" << std::endl;
+#endif
// La propriété de la données N'EST PAS transmise à l'utilisateur en mode CALCIUM
// Si l'utilisateur supprime la donnée, storedDataIds devient incohérent
CorbaPortTypePtr port = CorbaPortType::_narrow((*_my_ports)[i]);
//if (i) { PB1
copyOfData = DataManipulator::clone(data);
+#ifdef _DEBUG_
std::cout << "-------- GenericUsesPort::put : Copie de data("
//<< DataManipulator::getPointer(data)
<<") vers copyOfData ("
<<DataManipulator::getPointer(copyOfData)
<<")------------------" << std::endl;
+#endif
//} PB1
try {
port->put(*copyOfData,time,tag); // catcher les exceptions
{
if (_my_ports) delete _my_ports;
+#ifdef _DEBUG_
std::cerr << "GenericUsesPort::uses_port_changed" << endl;
+#endif
_my_ports = new Engines::DSC::uses_port(*new_uses_port);
}
# Author : André RIBES (EDF)
# Module : KERNEL
-SUBDIRS = Basic Datastream
include $(top_srcdir)/salome_adm/unix/make_common_starter.am
test_DSC_Exception_LDADD = $(top_builddir)/src/Utils/libOpUtil.la
+SUBDIRS = Basic Datastream
bool notif) :
Engines_DSC_i(orb, poa, contId, instanceName, interfaceName)
{
+#ifdef _DEBUG_
std::cout << "--Superv_Component_i : MARK 1 ---- " << instanceName << "----" << std::endl;
+#endif
_my_basic_factory = new basic_port_factory();
_my_palm_factory = new palm_port_factory();
_my_calcium_factory = new calcium_port_factory();
search_result = the_type.find("CALCIUM_");
if (search_result == 0) {
+#ifdef _DEBUG_
std::cout << "---- Superv_Component_i::create_uses_data_port : MARK 1 ---- " << the_type.substr(search_result+8, the_type.length()) << "----" << std::endl;
+#endif
rtn_proxy = _my_calcium_factory->create_data_proxy(the_type.substr(search_result+8, the_type.length()));
}
add_port(port, port_name);
}
else if (s_port_type == "uses") {
+#ifdef _DEBUG_
std::cout << "---- 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;
+#endif
add_port(port, port_name);
}
else
assert(port_name);
SpecificPortType * retPort;
+#ifdef _DEBUG_
std::cout << "---- Superv_Component_i::add_port : Mark 0 ---- " << port_name << "----" << std::endl;
+#endif
std::string s_port_type(port_type);
if (s_port_type == "provides") {
else if (s_port_type == "uses") {
uses_port * port = create_uses_data_port(port_fab_type);
add_port(port, port_name);
+#ifdef _DEBUG_
std::cout << "---- Superv_Component_i::add_port : Mark 1 ---- " << port << "----" << std::endl;
std::cout << "---- Superv_Component_i::add_port : Mark 1 ---- get_repository_id()" << port->get_repository_id() << std::endl;
+#endif
retPort = dynamic_cast<SpecificPortType *>(port);
+#ifdef _DEBUG_
std::cout << "---- Superv_Component_i::add_port : Mark 2 ---- " << retPort << "----" << std::endl;
+#endif
if ( retPort == NULL ) { delete port;
throw BadCast( LOC("La conversion vers le type de port demandé n'est pas possible " ));
}
SUBDIR_PAR = ParallelDSC
endif
-SUBDIRS = DSC_Basic DSC_User $(SUBDIR_PAR)
+SUBDIRS = DSC_Basic DSC_User $(SUBDIR_PAR) DSC_Python
Engines_Parallel_Component_i(orb, ior, poa, contId, instanceName, interfaceName, notif),
Engines::Parallel_DSC_serv(orb, ior),
Engines::DSC_serv(orb, ior),
-// Engines::Superv_Component_serv(orb, ior),
+ Engines::Superv_Component_serv(orb, ior),
Engines::Component_serv(orb, ior),
+ Engines::Parallel_Component_serv(orb, ior),
InterfaceParallel_impl(orb,ior)
{
}
virtual ~Engines_ParallelDSC_i();
- //virtual CORBA::Boolean init_service(const char* service_name) {return true;}
-
/*!
* \see Engines::DSC::add_provides_port
*/
#include "HDFOI.hxx"
-#include <OSD_Path.hxx>
-#include <OSD_File.hxx>
-#include <OSD_Protection.hxx>
-#include <OSD_Directory.hxx>
-#include <TCollection_AsciiString.hxx>
+//#include <OSD_Path.hxx>
+//#include <OSD_File.hxx>
+//#include <OSD_Protection.hxx>
+//#include <OSD_Directory.hxx>
+//#include <TCollection_AsciiString.hxx>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <sstream>
+#include <fstream>
#ifdef WNT
#include <io.h>
char* restoreName(char* name);
void write_float64(FILE* fp, hdf_float64* value);
void read_float64(FILE* fp, hdf_float64* value);
+bool directoryExists(const char* dir);
+bool createDirectory(const char* dir);
+bool is_readable( const std::string & file );
#define MAX_STRING_SIZE 65535
#define MAX_ID_SIZE 20
bool isReplace,
const char* theExtension)
{
- TCollection_AsciiString aPath((char*)thePath);
+ //TCollection_AsciiString aPath((char*)thePath);
+ std::string aPath((char*)thePath);
if(!isReplace) {
if(theExtension == NULL) aPath += ".asc";
else aPath += (char*)theExtension;
}
- TCollection_AsciiString aFileName(aPath);
+ //TCollection_AsciiString aFileName(aPath);
+ std::string aFileName(aPath);
if(isReplace) aFileName=aPath+".ascii_tmp";
HDFfile *hdf_file = new HDFfile((char*)thePath);
char name[HDF_NAME_MAX_LEN+1];
int nbsons = hdf_file->nInternalObjects(), nbAttr = hdf_file->nAttributes();
- FILE* fp = fopen(aFileName.ToCString(), "w");
+ //FILE* fp = fopen(aFileName.ToCString(), "w");
+ FILE* fp = fopen(aFileName.c_str(), "w");
fprintf(fp, "%s\n", ASCIIHDF_ID);
fprintf(fp, "%i\n", nbsons+nbAttr);
hdf_attribute = 0;
}
- for (Standard_Integer i=0; i<nbsons; i++) {
+ //for (Standard_Integer i=0; i<nbsons; i++) {
+ for (int i=0; i<nbsons; i++) {
hdf_file->InternalObjectIndentify(i,name);
if (strncmp(name, "INTERNAL_COMPLEX",16) == 0) continue;
delete hdf_file;
if(isReplace) {
- OSD_Path anOSDPath(aFileName);
- OSD_File anOSDFile(anOSDPath);
- if(anOSDFile.Exists())
- anOSDFile.Move(aPath);
- else
+// OSD_Path anOSDPath(aFileName);
+// OSD_File anOSDFile(anOSDPath);
+// if(anOSDFile.Exists())
+// anOSDFile.Move(aPath);
+// else
+// return NULL;
+ if(access (aFileName.c_str() , F_OK ) == 0) {
+ rename(aFileName.c_str(), aPath.c_str());
+ }
+ else
return NULL;
}
- int length = strlen(aPath.ToCString());
+ //int length = strlen(aPath.ToCString());
+ int length = strlen(aPath.c_str());
char *new_str = new char[ 1+length ];
- strcpy(new_str , aPath.ToCString()) ;
+ //strcpy(new_str , aPath.ToCString()) ;
+ strcpy(new_str , aPath.c_str()) ;
return new_str;
}
{
hdf_group->OpenOnDisk();
- TCollection_AsciiString anIdent(ident, '\t');
+ //TCollection_AsciiString anIdent(ident, '\t');
+ std::ostringstream oss;
+ oss << ident;
+ std::string anIdent(oss.str());
int nbsons = hdf_group->nInternalObjects(), nbAttr = hdf_group->nAttributes();
/*fprintf(fp, "%s%s\n", anIdent.ToCString(), GROUP_ID);*/
hdf_byte_order order = hdf_dataset->GetOrder();
int nbAttr = hdf_dataset->nAttributes();
- TCollection_AsciiString anIdent(ident, '\t');
- TCollection_AsciiString anIdentChild(ident+1, '\t');
+// TCollection_AsciiString anIdent(ident, '\t');
+// TCollection_AsciiString anIdentChild(ident+1, '\t');
+ std::ostringstream oss;
+ std::ostringstream oss2;
+ oss << ident;
+ oss2 << ident+1;
+ std::string anIdent(oss.str());
+ std::string anIdentChild(oss2.str());
char* name = makeName(hdf_dataset->GetName());
hdf_type type = hdf_attribute->GetType();
- TCollection_AsciiString anIdent(ident, '\t');
- TCollection_AsciiString anIdentChild(ident+1, '\t');
+ //TCollection_AsciiString anIdent(ident, '\t');
+ //TCollection_AsciiString anIdentChild(ident+1, '\t');
+ std::ostringstream oss;
+ std::ostringstream oss2;
+ oss << ident;
+ oss2 << ident+1;
+ std::string anIdent(oss.str());
+ std::string anIdentChild(oss2.str());
char* name = makeName(hdf_attribute->GetName());
int size = hdf_attribute->GetSize();
char* HDFascii::ConvertFromASCIIToHDF(const char* thePath)
{
// Get a temporary directory to store a file
- TCollection_AsciiString aTmpDir = GetTmpDir(), aFileName("hdf_from_ascii.hdf");
+ //TCollection_AsciiString aTmpDir = GetTmpDir(), aFileName("hdf_from_ascii.hdf");
+ std::string aTmpDir = GetTmpDir();
+ std::string aFileName("hdf_from_ascii.hdf");
// Build a full file name of temporary file
- TCollection_AsciiString aFullName = aTmpDir + aFileName;
+ //TCollection_AsciiString aFullName = aTmpDir + aFileName;
+ std::string aFullName = aTmpDir + aFileName;
- HDFfile *hdf_file = new HDFfile(aFullName.ToCString());
+ //HDFfile *hdf_file = new HDFfile(aFullName.ToCString());
+ HDFfile *hdf_file = new HDFfile((char *) aFullName.c_str());
hdf_file->CreateOnDisk();
FILE *fp = fopen(thePath, "r");
hdf_file->CloseOnDisk();
delete hdf_file;
- int length = strlen(aTmpDir.ToCString());
+ //int length = strlen(aTmpDir.ToCString());
+ int length = strlen(aTmpDir.c_str());
+ cerr << "length : " << length << endl;
char *new_str = new char[ 1+length ];
- strcpy(new_str , aTmpDir.ToCString()) ;
+ //strcpy(new_str , aTmpDir.ToCString()) ;
+ strcpy(new_str , aTmpDir.c_str()) ;
+
+ cerr << "test ::: " << aTmpDir << endl;
+ cerr << "test ::: " << new_str << endl;
return new_str;
}
{
//Find a temporary directory to store a file
- TCollection_AsciiString aTmpDir;
+ //TCollection_AsciiString aTmpDir;
+ std::string aTmpDir;
#ifdef WNT
char *aTmp;
aTmp = getenv("TMP");
- if(aTmp != NULL)
- aTmpDir = TCollection_AsciiString(aTmp);
- else
- aTmpDir = TCollection_AsciiString("C:\\");
+ if(aTmp != NULL) {
+// aTmpDir = TCollection_AsciiString(aTmp);
+ aTmpDir = std::string(aTmp);
+ }
+ else {
+// aTmpDir = TCollection_AsciiString("C:\\");
+ aTmpDir = std::string("C:\\");
+ }
#else
- aTmpDir = TCollection_AsciiString("/tmp/");
+ //aTmpDir = TCollection_AsciiString("/tmp/");
+ aTmpDir = std::string("/tmp/");
#endif
srand((unsigned int)time(NULL));
int aRND = 999 + (int)(100000.0*rand()/(RAND_MAX+1.0)); //Get a random number to present a name of a sub directory
- TCollection_AsciiString aSubDir(aRND);
- if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876");
+// TCollection_AsciiString aSubDir(aRND);
+// if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876");
+ std::ostringstream oss;
+ oss << aRND;
+ std::string aSubDir(oss.str());
+ if(aSubDir.length() <= 1) aSubDir = std::string("123409876");
aTmpDir += aSubDir; //Get RND sub directory
#ifdef WIN32
- if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
+// if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
+ if(aTmpDir[aTmpDir.length()-1] != '\\') aTmpDir+='\\';
#else
- if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
+// if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
+ if(aTmpDir[aTmpDir.length()-1] != '/') aTmpDir+='/';
#endif
- OSD_Path aPath(aTmpDir);
- OSD_Directory aDir(aPath);
+// OSD_Path aPath(aTmpDir);
+// OSD_Directory aDir(aPath);
+ std::string aDir(aTmpDir);
- for(aRND = 0; aDir.Exists(); aRND++) {
- aTmpDir.Insert((aTmpDir.Length() - 1), TCollection_AsciiString(aRND)); //Build a unique directory name
- aPath = OSD_Path(aTmpDir);
- aDir = OSD_Directory(aPath);
- }
+ //std::cerr << "temp dir .... : " << aTmpDir << std::endl;
- OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX);
- aDir.Build(aProtection);
+ for(aRND = 0; directoryExists(aDir.c_str()); aRND++) {
+ //aTmpDir.Insert((aTmpDir.Length() - 1), TCollection_AsciiString(aRND)); //Build a unique directory name
+ aTmpDir.insert((aTmpDir.length() - 1), oss.str()); //Build a unique directory name
+ std::cerr << "Tempory directory exist, changing name ..." << std::endl;
+ std::cerr << "temp dir .... : " << aTmpDir << std::endl;
+ aDir = std::string(aTmpDir);
+// aPath = OSD_Path(aTmpDir);
+// aDir = OSD_Directory(aPath);
+ }
- int length = strlen(aTmpDir.ToCString());
+ //OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX);
+ //aDir.Build(aProtection);
+ createDirectory(aDir.c_str());
+ //int length = strlen(aTmpDir.ToCString());
+ int length = strlen(aTmpDir.c_str());
char *new_str = new char[ 1+length ];
- strcpy(new_str , aTmpDir.ToCString());
-
+ //strcpy(new_str , aTmpDir.ToCString());
+ strcpy(new_str , aTmpDir.c_str());
return new_str;
}
char* makeName(char* name)
{
- TCollection_AsciiString aName(name), aNewName;
- Standard_Integer i, length = aName.Length();
+ //TCollection_AsciiString aName(name), aNewName;
+ std::string aName(name), aNewName;
+ //Standard_Integer i, length = aName.Length();
+ int i, length = aName.length();
char replace = (char)19;
for(i=1; i<=length; i++) {
- if(aName.Value(i) == ' ') aNewName+=replace;
- else aNewName += aName.Value(i);
+ //if(aName.Value(i) == ' ') aNewName+=replace;
+ //else aNewName += aName.Value(i);
+ if(aName[i] == ' ') aNewName+=replace;
+ else aNewName += aName[i];
}
- length = strlen(aNewName.ToCString());
+ //length = strlen(aNewName.ToCString());
+ length = strlen(aNewName.c_str());
char *new_str = new char[ 1+length ];
- strcpy(new_str , aNewName.ToCString()) ;
+ //strcpy(new_str , aNewName.ToCString()) ;
+ strcpy(new_str , aNewName.c_str()) ;
return new_str;
}
char* restoreName(char* name)
{
- TCollection_AsciiString aName(name), aNewName;
- Standard_Integer i, length = aName.Length();
+ //TCollection_AsciiString aName(name), aNewName;
+ std::string aName(name), aNewName;
+ //Standard_Integer i, length = aName.Length();
+ int i, length = aName.length();
char replace = (char)19;
for(i=1; i<=length; i++) {
- if(aName.Value(i) == replace) aNewName+=' ';
- else aNewName += aName.Value(i);
+ //if(aName.Value(i) == replace) aNewName+=' ';
+ //else aNewName += aName.Value(i);
+ if(aName[i] == replace) aNewName+=' ';
+ else aNewName += aName[i];
}
- length = strlen(aNewName.ToCString());
+ //length = strlen(aNewName.ToCString());
+ length = strlen(aNewName.c_str());
char *new_str = new char[ 1+length ];
- strcpy(new_str , aNewName.ToCString()) ;
+ //strcpy(new_str , aNewName.ToCString()) ;
+ strcpy(new_str , aNewName.c_str()) ;
return new_str;
}
array[i] = (unsigned char)tmp;
}
}
+
+bool directoryExists(const char* dir)
+{
+ DIR* dhandle = opendir(dir);
+
+ if (dhandle != NULL)
+ {
+ closedir(dhandle);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool createDirectory(const char* dir)
+{
+ return mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0;
+}
+
+bool is_readable( const std::string & file )
+{
+ std::ifstream fichier( file.c_str() );
+ return !fichier.fail();
+}
#ifndef __HDFascii_H__
#define __HDFascii_H__
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFascii
+class HDF_EXPORT HDFascii
{
public:
}
#include "HDFcontainerObject.hxx"
#include "HDFexception.hxx"
-#include "utilities.h"
+//#include "utilities.h"
using namespace std;
-HDFcontainerObject::HDFcontainerObject(char *name)
+HDFcontainerObject::HDFcontainerObject(const char *name)
: HDFinternalObject(name)
{
_nsons = 0;
}
#include "HDFobject.hxx"
#include "HDFinternalObject.hxx"
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFcontainerObject : public HDFinternalObject
+class HDF_EXPORT HDFcontainerObject : public HDFinternalObject
{
private :
HDFinternalObject *_firstson;
HDFinternalObject *_lastson;
int _nsons;
public :
- HDFcontainerObject(char *name);
+ HDFcontainerObject(const char *name);
virtual ~HDFcontainerObject();
virtual int nInternalObjects();
return 1;
}
-HDFdataset::HDFdataset(char *name, HDFcontainerObject *father,hdf_type type,
+HDFdataset::HDFdataset(const char *name, HDFcontainerObject *father,hdf_type type,
hdf_size dim[], int dimsize, hdf_byte_order order)
: HDFinternalObject(name)
{
}
-HDFdataset::HDFdataset(char *name,HDFcontainerObject *father)
+HDFdataset::HDFdataset(const char *name,HDFcontainerObject *father)
: HDFinternalObject(name)
{
_father = father;
}
#include "HDFinternalObject.hxx"
#include "HDFcontainerObject.hxx"
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFdataset : public HDFinternalObject
+class HDF_EXPORT HDFdataset : public HDFinternalObject
{
private :
HDFcontainerObject *_father;
char* _attribute;
public:
- HDFdataset(char *name, HDFcontainerObject *father,hdf_type type,
+ HDFdataset(const char *name, HDFcontainerObject *father,hdf_type type,
hdf_size dim[],int dimsize, hdf_byte_order order = H5T_ORDER_NONE);
- HDFdataset(char *name,HDFcontainerObject *father);
+ HDFdataset(const char *name,HDFcontainerObject *father);
virtual ~HDFdataset();
void CreateOnDisk();
--- /dev/null
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : HDFexport.hxx
+// Author : Andre Ribes - EDF R&D
+// Module : SALOME
+
+#ifndef _HDF_export_HXX_
+#define _HDF_export_HXX_
+
+#ifdef WNT
+ #if defined WIN32
+ #define HDF_EXPORT __declspec( dllimport )
+ #else
+ #define HDF_EXPORT
+ #endif
+#else
+ #define HDF_EXPORT
+#endif
+
+#endif
#include "HDFtypes.h"
}
#include "HDFcontainerObject.hxx"
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFfile : public HDFcontainerObject
+class HDF_EXPORT HDFfile : public HDFcontainerObject
{
private :
hdf_access_mode _access_mode;
return 1;
}
-HDFgroup::HDFgroup(char *name, HDFcontainerObject *father)
+HDFgroup::HDFgroup(const char *name, HDFcontainerObject *father)
: HDFcontainerObject(name)
{
_father = father;
#include "HDFtypes.h"
}
#include "HDFcontainerObject.hxx"
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFgroup : public HDFcontainerObject
+class HDF_EXPORT HDFgroup : public HDFcontainerObject
{
private :
HDFcontainerObject *_father;
hdf_idt _mid;
char* _attribute;
public :
- HDFgroup(char *name, HDFcontainerObject *father);
+ HDFgroup(const char *name, HDFcontainerObject *father);
void CreateOnDisk();
void OpenOnDisk();
using namespace std;
#endif
-HDFinternalObject::HDFinternalObject(char *name)
+HDFinternalObject::HDFinternalObject(const char *name)
: HDFobject(name)
{
_previousbrother = NULL;
#include "HDFtypes.h"
}
#include "HDFobject.hxx"
-#include <Standard_Macro.hxx>
+#include "HDFexport.hxx"
-class Standard_EXPORT HDFinternalObject : public HDFobject
+class HDF_EXPORT HDFinternalObject : public HDFobject
{
private :
HDFinternalObject *_previousbrother;
HDFinternalObject *_nextbrother;
public :
- HDFinternalObject(char *name);
+ HDFinternalObject(const char *name);
HDFinternalObject *GetPreviousBrother();
HDFinternalObject *GetNextBrother();
#include "hdfi.h"
#include <string.h>
}
-#include "utilities.h"
+//#include "utilities.h"
using namespace std;
-HDFobject::HDFobject(char *name)
+HDFobject::HDFobject(const char *name)
{
// MESSAGE("-------- constructor " << name << " " << this);
HDFerrorModeLock();
{
#include "HDFtypes.h"
}
-#include <Standard_Macro.hxx>
+#include <HDFexport.hxx>
-class Standard_EXPORT HDFobject {
+class HDF_EXPORT HDFobject {
protected :
char *_name;
hdf_idt _id;
public :
- HDFobject(char *name);
+ HDFobject(const char *name);
virtual ~HDFobject();
hdf_idt GetId();
HDFtypes.h \
HDFconvert.hxx \
hdfi.h \
- HDFascii.hxx
+ HDFascii.hxx \
+ HDFexport.hxx
# Libraries targets
lib_LTLIBRARIES = libSalomeHDFPersist.la
HDFascii.cc
libSalomeHDFPersist_la_LDFLAGS = -no-undefined -version-info=0:0:0
-libSalomeHDFPersist_la_CPPFLAGS = @CAS_CPPFLAGS@ @HDF5_INCLUDES@ -DPCLINUX \
+
+#libSalomeHDFPersist_la_CPPFLAGS = @CAS_CPPFLAGS@ @HDF5_INCLUDES@ -DPCLINUX \
+libSalomeHDFPersist_la_CPPFLAGS = @HDF5_INCLUDES@ -DPCLINUX \
-I$(srcdir)/../SALOMELocalTrace \
-I$(srcdir)/../Basics
-libSalomeHDFPersist_la_LIBADD = @CAS_KERNEL@ @HDF5_LIBS@
-
+#libSalomeHDFPersist_la_LIBADD = @CAS_KERNEL@ @HDF5_LIBS@
+libSalomeHDFPersist_la_LIBADD = @HDF5_LIBS@
EXTRA_DIST = \
test1.c \
SALOME_ModuleCatalog::ModuleCatalog_var Catalog =
SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ;
ASSERT(! CORBA::is_nil(Catalog));
- SALOME_ModuleCatalog::Acomponent_ptr compoInfo =
+ SALOME_ModuleCatalog::Acomponent_var compoInfo =
Catalog->GetComponent(componentName);
if (CORBA::is_nil (compoInfo))
{
params.nb_proc_per_node = 0;
params.nb_node = 0;
params.isMPI = false;
+
+ params.parallelLib = "";
+ params.nb_component_nodes = 0;
}
//=============================================================================
import sys, os,signal,string,commands
import runSalome
+import setenv
import orbmodule
import TestKiller
import addToKillList
# get SALOME environment :
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
# set environment for trace in logger
# (with file, servers may be killed before the write to the file...)
import sys, os,signal,string,commands
import runSalome
+import setenv
import orbmodule
import TestKiller
import addToKillList
# get SALOME environment :
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
# set environment for trace in logger
# (with file, servers may be killed before the write to the file...)
#
import sys, os,signal,string,commands
import runSalome
+import setenv
import orbmodule
import TestKiller
# get SALOME environment :
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
# set environment for trace in logger
# (with file, servers may be killed before the write to the file...)
#
# header files
salomeinclude_HEADERS = SALOME_ParallelComponent_i.hxx \
- SALOME_ParallelContainer_i.hxx
+ SALOME_ParallelContainer_i.hxx \
+ Parallel_Salome_file_i.hxx
#
# ===============================================================
-I$(top_srcdir)/src/NamingService \
-I$(top_srcdir)/src/Registry \
-I$(top_srcdir)/src/Utils \
+ -I$(srcdir)/../HDFPersist \
-I$(top_builddir)/salome_adm/unix \
-I$(top_builddir)/idl \
-I$(top_srcdir)/src/SALOMETraceCollector \
# This local variable defines the list of dependant libraries common to all target in this package.
COMMON_LIBS = $(top_builddir)/src/Container/libSalomeContainer.la \
+ $(top_builddir)/src/HDFPersist/libSalomeHDFPersist.la \
$(top_builddir)/idl/libSalomeParallelIDLKernel.la \
+ $(top_builddir)/idl/libSalomeIDLKernel.la \
@CORBA_LIBS@ \
@PACO_LIBS@
lib_LTLIBRARIES = libSalomeParallelContainer.la
libSalomeParallelContainer_la_SOURCES = SALOME_ParallelComponent_i.cxx \
- SALOME_ParallelContainer_i.cxx
+ SALOME_ParallelContainer_i.cxx \
+ $(top_srcdir)/src/Container/Salome_file_i.cxx \
+ Parallel_Salome_file_i.cxx
libSalomeParallelContainer_la_CXXFLAGS = $(COMMON_CPPFLAGS)
SALOME_ParallelContainerProxyDummy_SOURCES = SALOME_ParallelContainerProxyDummy.cxx
SALOME_ParallelContainerProxyDummy_CXXFLAGS = $(COMMON_CPPFLAGS)
SALOME_ParallelContainerProxyDummy_LDADD = libSalomeParallelContainer.la \
- -L@PACOPATH@/lib -lPaCO_dummy -lPaCO_omnithread
+ -L@PACOPATH@/lib -lPaCO_dummy -lPaCO_omnithread \
+ $(COMMON_LIBS)
SALOME_ParallelContainerNodeDummy_SOURCES = SALOME_ParallelContainerNodeDummy.cxx
SALOME_ParallelContainerNodeDummy_CXXFLAGS = $(COMMON_CPPFLAGS)
SALOME_ParallelContainerNodeDummy_LDADD = libSalomeParallelContainer.la \
- -L@PACOPATH@/lib -lPaCO_dummy -lPaCO_omnithread
+ -L@PACOPATH@/lib -lPaCO_dummy -lPaCO_omnithread \
+ $(COMMON_LIBS)
SALOME_ParallelContainerProxyMpi_SOURCES = SALOME_ParallelContainerProxyMpi.cxx
SALOME_ParallelContainerProxyMpi_CXXFLAGS = $(COMMON_CPPFLAGS) @MPI_INCLUDES@
SALOME_ParallelContainerProxyMpi_LDADD = libSalomeParallelContainer.la \
-L@PACOPATH@/lib -lPaCO_dummy -lPaCO_mpi -lPaCO_omnithread \
- @MPI_LIBS@
+ @MPI_LIBS@ \
+ $(COMMON_LIBS)
+
SALOME_ParallelContainerNodeMpi_SOURCES = SALOME_ParallelContainerNodeMpi.cxx
SALOME_ParallelContainerNodeMpi_CXXFLAGS = $(COMMON_CPPFLAGS) @MPI_INCLUDES@
SALOME_ParallelContainerNodeMpi_LDADD = libSalomeParallelContainer.la \
-L@PACOPATH@/lib -lPaCO_dummy -lPaCO_mpi -lPaCO_omnithread \
- @MPI_LIBS@
+ @MPI_LIBS@\
+ $(COMMON_LIBS)
+
--- /dev/null
+// Copyright (C) 2007 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : Parallel_Salome_file_i.cxx
+// Author : André RIBES, EDF
+// Module : SALOME
+// $Header:
+
+#include "Parallel_Salome_file_i.hxx"
+#include "utilities.h"
+
+Parallel_Salome_file_i::Parallel_Salome_file_i(CORBA::ORB_ptr orb, const char * ior) :
+ InterfaceParallel_impl(orb,ior),
+ Engines::Salome_file_serv(orb,ior),
+ Engines::fileTransfer_serv(orb,ior),
+ Engines::Parallel_Salome_file_serv(orb,ior)
+{
+ CORBA::Object_ptr obj = _orb->string_to_object(ior);
+ proxy = Engines::Parallel_Salome_file::_narrow(obj);
+ parallel_file = NULL;
+}
+
+Parallel_Salome_file_i::~Parallel_Salome_file_i() {}
+
+void
+Parallel_Salome_file_i::load(const char* hdf5_file) {
+ MESSAGE("Parallel_Salome_file_i::load : NOT YET IMPLEMENTED");
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "Parallel_Salome_file_i::load : NOT YET IMPLEMENTED";
+ throw SALOME::SALOME_Exception(es);
+}
+
+void
+Parallel_Salome_file_i::save(const char* hdf5_file) {
+ MESSAGE("Parallel_Salome_file_i::save : NOT YET IMPLEMENTED");
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "Parallel_Salome_file_i::save : NOT YET IMPLEMENTED";
+ throw SALOME::SALOME_Exception(es);
+}
+
+void
+Parallel_Salome_file_i::save_all(const char* hdf5_file) {
+ MESSAGE("Parallel_Salome_file_i::save_all : NOT YET IMPLEMENTED");
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "Parallel_Salome_file_i::save_all : NOT YET IMPLEMENTED";
+ throw SALOME::SALOME_Exception(es);
+}
+
+void
+Parallel_Salome_file_i::connect(Engines::Salome_file_ptr source_Salome_file) {
+ // only one file managed case
+ Salome_file_i::connect(source_Salome_file);
+
+ // Test if the file is managed in an another node
+ // If yes, node is updated
+ _t_fileManaged::iterator begin = _fileManaged.begin();
+ _t_fileManaged::iterator end = _fileManaged.end();
+ for(;begin!=end;begin++) {
+ std::string file_name = begin->first;
+ if (_fileManaged[file_name].node > 0 && getMyRank() == 0) {
+ if (parallel_file == NULL)
+ parallel_file = Engines::PaCO_Parallel_Salome_file::PaCO_narrow(proxy, _orb);
+ parallel_file->connect(source_Salome_file, _fileManaged[file_name].node);
+ }
+ }
+}
+
+void
+Parallel_Salome_file_i::connectDistributedFile(const char * file_name,
+ Engines::Salome_file_ptr source_Salome_file) {
+ Salome_file_i::connectDistributedFile(file_name, source_Salome_file);
+
+ // Test if the file is managed in an another node
+ // If yes, node is updated
+ std::string fname(file_name);
+ if (_fileManaged[fname].node > 0 && getMyRank() == 0) {
+ if (parallel_file == NULL)
+ parallel_file = Engines::PaCO_Parallel_Salome_file::PaCO_narrow(proxy, _orb);
+ parallel_file->connectDistributedFile(file_name, source_Salome_file, _fileManaged[fname].node);
+ }
+}
+
+void
+Parallel_Salome_file_i::setDistributedSourceFile(const char* file_name,
+ const char * source_file_name) {
+ Salome_file_i::setDistributedSourceFile(file_name, source_file_name);
+ // Test if the file is managed in an another node
+ // If yes, node is updated
+ std::string fname(file_name);
+ if (_fileManaged[fname].node > 0 && getMyRank() == 0) {
+ if (parallel_file == NULL)
+ parallel_file = Engines::PaCO_Parallel_Salome_file::PaCO_narrow(proxy, _orb);
+ parallel_file->setDistributedSourceFile(file_name, source_file_name, _fileManaged[fname].node);
+ }
+}
+
+void
+Parallel_Salome_file_i::recvFiles() {
+ if (parallel_file == NULL)
+ parallel_file = Engines::PaCO_Parallel_Salome_file::PaCO_narrow(proxy, _orb);
+
+ std::string files_not_ok("");
+ int total = getTotalNode();
+ for (int i =0; i<total; i++) {
+ try {
+ parallel_file->recvFiles_node(i);
+ }
+ catch (SALOME::SALOME_Exception & ex) {
+ files_not_ok = files_not_ok + std::string(ex.details.text.in());
+ }
+ }
+
+ if (files_not_ok != "")
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = "files not ready : " + files_not_ok;
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+ else
+ {
+ // We change the state of the Salome_file
+ _state.files_ok = true;
+ }
+}
+
+void
+Parallel_Salome_file_i::recvFiles_node() {
+
+ std::string files_not_ok("");
+ _t_fileManaged::iterator begin = _fileManaged.begin();
+ _t_fileManaged::iterator end = _fileManaged.end();
+ for(;begin!=end;begin++)
+ {
+ bool result = true;
+ Engines::file file_infos = begin->second;
+ if (file_infos.node == getMyRank()) {
+ // Test if the file is local or distributed
+ if (std::string(file_infos.type.in()) == "local")
+ {
+ if (std::string(file_infos.status.in()) == "not_ok")
+ result = checkLocalFile(file_infos.file_name.in());
+ }
+ else
+ {
+ if (std::string(file_infos.status.in()) == "not_ok") {
+ // 2 cases :
+ // Source file is a Salome_file
+ // Source file is a Parallel_Salome_file
+ PaCO::ParallelKernel_var interface_manager =
+ PaCO::ParallelKernel::_narrow(_fileDistributedSource[file_infos.file_name.in()]);
+ if (CORBA::is_nil(interface_manager))
+ result = getDistributedFile(file_infos.file_name.in());
+ else
+ result = getParallelDistributedFile(file_infos.file_name.in());
+ }
+ }
+ // if the result is false
+ // we add this file to files_not_ok
+ if (!result)
+ {
+ files_not_ok.append(" ");
+ files_not_ok.append(file_infos.file_name.in());
+ }
+ }
+ }
+ if (files_not_ok != "")
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ std::string text = files_not_ok;
+ es.text = CORBA::string_dup(text.c_str());
+ throw SALOME::SALOME_Exception(es);
+ }
+}
+
+bool
+Parallel_Salome_file_i::getParallelDistributedFile(std::string file_name) {
+
+ bool result = true;
+ const char * source_file_name = _fileManaged[file_name].source_file_name.in();
+ int fileId;
+ FILE* fp;
+ std::string comp_file_name(_fileManaged[file_name].path.in());
+ comp_file_name.append("/");
+ comp_file_name.append(_fileManaged[file_name].file_name.in());
+
+ // Test if the process can write on disk
+ if ((fp = fopen(comp_file_name.c_str(),"wb")) == NULL)
+ {
+ INFOS("file " << comp_file_name << " cannot be open for writing");
+ _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+ result = false;
+ return result;
+ }
+
+ Engines::PaCO_Parallel_Salome_file * parallel_source_file =
+ Engines::PaCO_Parallel_Salome_file::PaCO_narrow(_fileDistributedSource[file_name], _orb);
+
+ int node = parallel_source_file->getFileNode(source_file_name);
+
+ try
+ {
+ fileId = parallel_source_file->open(source_file_name, node);
+ }
+ catch (...)
+ {
+ _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+ fclose(fp);
+ result = false;
+ return result;
+ }
+
+ if (fileId > 0)
+ {
+ Engines::fileBlock* aBlock;
+ int toFollow = 1;
+ int ctr=0;
+ MESSAGE("begin of transfer of " << comp_file_name);
+ while (toFollow)
+ {
+ ctr++;
+ aBlock = parallel_source_file->getBlock(fileId, node);
+ toFollow = aBlock->length();
+ CORBA::Octet *buf = aBlock->get_buffer();
+ int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
+ ASSERT(nbWri == toFollow);
+ }
+ fclose(fp);
+ MESSAGE("end of transfer of " << comp_file_name);
+ parallel_source_file->close(fileId, node);
+ }
+ else
+ {
+ INFOS("open reference file for copy impossible");
+ result = false;
+ fclose(fp);
+ _fileManaged[file_name].status = CORBA::string_dup("not_ok");
+ return result;
+ }
+
+ _fileManaged[file_name].status = CORBA::string_dup("ok");
+ return result;
+}
+
+void
+Parallel_Salome_file_i::setContainer(Engines::Container_ptr container) {
+ _container = Engines::Container::_duplicate(container);
+
+ // Update All the files managed by the node
+ _t_fileManaged::iterator begin = _fileManaged.begin();
+ _t_fileManaged::iterator end = _fileManaged.end();
+ for(;begin!=end;begin++) {
+ begin->second.container = Engines::Container::_duplicate(container);
+ }
+}
+
+void
+Parallel_Salome_file_i::setFileNode(const char* file_name, CORBA::Long node) {
+
+ // Test if this file is managed
+ std::string fname(file_name);
+ _t_fileManaged::iterator it = _fileManaged.find(fname);
+ if (it == _fileManaged.end())
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "file is not managed";
+ throw SALOME::SALOME_Exception(es);
+ }
+
+ // Update file infos into this node (node 0)
+ // and into the node that actually managed it
+ _fileManaged[fname].node = node;
+
+ if (node > 0) {
+ if (parallel_file == NULL)
+ parallel_file = Engines::PaCO_Parallel_Salome_file::PaCO_narrow(proxy, _orb);
+
+ Engines::Container_ptr cont = parallel_file->updateFile(_fileManaged[fname], node);
+ parallel_file->connectDistributedFile(fname.c_str(),
+ _fileDistributedSource[fname],
+ node);
+
+ // Update file infos with the new reference of the container
+ _fileManaged[fname].container = Engines::Container::_duplicate(cont);
+ }
+}
+
+Engines::Container_ptr
+Parallel_Salome_file_i::updateFile(const Engines::file& file) {
+ // Copy file
+ Engines::file new_file_infos(file);
+
+ // Adding it to node list
+ new_file_infos.container = Engines::Container::_duplicate(_container);
+ std::string fname(new_file_infos.file_name.in());
+ _fileManaged[fname] = new_file_infos;
+
+ // Return the new reference of the container associated to the file
+ return Engines::Container::_duplicate(_container);
+}
+
+CORBA::Long
+Parallel_Salome_file_i::getFileNode(const char* file_name) {
+
+ // Test if this file is managed
+ std::string fname(file_name);
+ if (fname == "") {
+ // We enter in the simple case where the user
+ // has not used setDistributedSourceFile.
+ // In this case we try to see if the Salome_file
+ if (_fileManaged.size() == 1)
+ {
+ // only one file managed
+ _t_fileManaged::iterator it = _fileManaged.begin();
+ fname = it->first;
+ }
+ else
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "Error : there is more than one file that is managed";
+ throw SALOME::SALOME_Exception(es);
+ }
+ }
+ _t_fileManaged::iterator it = _fileManaged.find(fname);
+ if (it == _fileManaged.end())
+ {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "file is not managed";
+ throw SALOME::SALOME_Exception(es);
+ }
+
+ return _fileManaged[fname].node;
+}
--- /dev/null
+// Copyright (C) 2007 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : Parallel_Salome_file_i.hxx
+// Author : André RIBES, EDF
+// Module : SALOME
+// $Header:
+
+#ifndef _PARALLEL_SALOME_FILE_I_HXX_
+#define _PARALLEL_SALOME_FILE_I_HXX_
+
+#include <SALOMEconfig.h>
+#include <SALOME_Container.hxx>
+#include <map>
+#include <cstdio>
+
+#include "SALOME_ComponentPaCO_Engines_Parallel_Salome_file_server.h"
+#include "Salome_file_i.hxx"
+
+class CONTAINER_EXPORT Parallel_Salome_file_i:
+ public virtual Salome_file_i,
+ public virtual Engines::Parallel_Salome_file_serv
+{
+ public:
+ Parallel_Salome_file_i(CORBA::ORB_ptr orb, const char * ior);
+ virtual ~Parallel_Salome_file_i();
+
+ virtual void setFileNode(const char* file_name, CORBA::Long node);
+ virtual CORBA::Long getFileNode(const char* file_name);
+ virtual Engines::Container_ptr updateFile(const Engines::file& file);
+
+ // New implementation for these methods
+ // For the parallel cases
+ virtual void load(const char* hdf5_file);
+ virtual void save(const char* hdf5_file);
+ virtual void save_all(const char* hdf5_file);
+ virtual void connect(Engines::Salome_file_ptr source_Salome_file);
+ virtual void connectDistributedFile(const char * file_name,
+ Engines::Salome_file_ptr source_Salome_file);
+ virtual void setDistributedSourceFile(const char* file_name,
+ const char * source_file_name);
+ virtual void recvFiles();
+ virtual void recvFiles_node();
+ virtual void setContainer(Engines::Container_ptr container);
+ //virtual void removeFile(const char* file_name);
+ //virtual void removeFiles();
+
+ // Local C++ methods
+ virtual bool getParallelDistributedFile(std::string file_name);
+
+ private :
+ Engines::Parallel_Salome_file_var proxy;
+ Engines::PaCO_Parallel_Salome_file * parallel_file;
+};
+
+#endif
+
int SIGUSR11 = 1000;
#endif
+#include <paco_dummy.h>
using namespace std;
//=============================================================================
Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior) :
- InterfaceParallel_impl(orb,ior), Engines::Component_serv(orb,ior)
+ InterfaceParallel_impl(orb,ior), Engines::Component_serv(orb,ior), Engines::Parallel_Component_serv(orb,ior)
{
//ASSERT(0);
INFOS("Default Constructor...");
const char *instanceName,
const char *interfaceName,
bool notif) :
- InterfaceParallel_impl(orb,ior), Engines::Component_serv(orb,ior),
+ InterfaceParallel_impl(orb,ior),
+ Engines::Component_serv(orb,ior),
+ Engines::Parallel_Component_serv(orb,ior),
_instanceName(instanceName),
_interfaceName(interfaceName),
_myConnexionToRegistry(0),
_instanceName.c_str());
_notifSupplier = new NOTIFICATION_Supplier(instanceName, notif);
- //SCRUTE(pd_refCount);
+
+ deploy_mutex = new pthread_mutex_t();
+ pthread_mutex_init(deploy_mutex, NULL);
+ _proxy = NULL;
+ //SCRUTE(pd_refCount);
}
//=============================================================================
{
MESSAGE("Component destructor");
Engines_Parallel_Container_i::decInstanceCnt(_interfaceName);
+ pthread_mutex_destroy(deploy_mutex);
+ delete deploy_mutex;
+
+ if (_proxy)
+ delete _proxy;
}
//=============================================================================
(*it).second >>= value;
// ---todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC.
#if defined __GNUC__
- int ret = setenv(cle.c_str(), value, overwrite);
+ //int ret = setenv(cle.c_str(), value, overwrite);
+ setenv(cle.c_str(), value, overwrite);
#else
//CCRT porting : setenv not defined in stdlib.h
std::string s(cle);
s+=value;
// char* cast because 1st arg of linux putenv function
// is not a const char* !
- int ret=putenv((char *)s.c_str());
+ //int ret=putenv((char *)s.c_str());
+ putenv((char *)s.c_str());
//End of CCRT porting
#endif
MESSAGE("--- setenv: "<<cle<<" = "<< value);
//=============================================================================
Engines::TMPFile* Engines_Parallel_Component_i::DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
- CORBA::Boolean& isValidScript)
+ CORBA::Boolean isPublished,
+ CORBA::Boolean& isValidScript)
{
- char* aScript = "def RebuildData(theStudy): pass";
+ const char* aScript = "def RebuildData(theStudy): pass";
char* aBuffer = new char[strlen(aScript)+1];
strcpy(aBuffer, aScript);
CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
isValidScript = true;
return aStreamFile._retn();
}
+
+
+Engines::Salome_file_ptr
+Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we add it.
+ _Service_file_map_it = _Input_Service_file_map.find(service_name);
+ if (_Service_file_map_it == _Input_Service_file_map.end()) {
+ _t_Salome_file_map * _map = new _t_Salome_file_map();
+ _Input_Service_file_map[service_name] = _map;
+ _t_Proxy_Salome_file_map * _proxy_map = new _t_Proxy_Salome_file_map();
+ _Proxy_Input_Service_file_map[service_name] = _proxy_map;
+ _t_IOR_Proxy_Salome_file_map * _IOR_proxy_map = new _t_IOR_Proxy_Salome_file_map();
+ _IOR_Proxy_Input_Service_file_map[service_name] = _IOR_proxy_map;
+ }
+ _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
+ _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Input_Service_file_map[service_name];
+ _t_IOR_Proxy_Salome_file_map * _IOR_proxy_map = _IOR_Proxy_Input_Service_file_map[service_name];
+
+ pthread_mutex_lock(deploy_mutex);
+ std::string proxy_ior;
+
+ // Try to find the Salome_file ...
+ _Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Salome_file_map_it == _map->end()) {
+
+ // We create a new PaCO++ object.
+ // He has the same configuration than
+ // his component
+
+ // Firstly, we have to create the proxy object
+ // of the Salome_file and transmit his
+ // reference to the other nodes.
+ if (getMyRank() == 0) {
+ Engines::Parallel_Salome_file_proxy_impl * proxy =
+ new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb));
+ PaCO_operation * proxy_global_ptr = proxy->getContext("global_paco_context");
+ // We initialize the object with the context of the Parallel component
+ PaCO_operation * compo_global_ptr = getContext("global_paco_context");
+ //compo_global_ptr->init_context(proxy_global_ptr);
+ proxy_global_ptr->init_context(compo_global_ptr);
+
+ paco_fabrique_manager* pfm = paco_getFabriqueManager();
+ pfm->register_com("dummy", new paco_dummy_fabrique());
+ proxy_global_ptr->setComFab(NULL);
+ proxy_global_ptr->setLibCom("dummy",NULL);
+
+ proxy_global_ptr->setTypeClient(true);
+ PaCO::PacoTopology_t client_topo;
+ client_topo.total = 1;
+ proxy_global_ptr->setClientTopo(client_topo);
+ PaCO::PacoTopology_t serveur_topo;
+ serveur_topo.total = getTotalNode();
+ proxy->setTopo(serveur_topo);
+
+ // We register the CORBA objet into the POA
+ CORBA::Object_ptr proxy_ref = proxy->_this();
+
+ // We send the reference to all the nodes...
+ CORBA::Object_ptr comp_proxy = _orb->string_to_object(_ior.c_str());
+ Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(comp_proxy);
+ component_proxy->send_parallel_proxy_object(proxy_ref);
+
+ // Adding proxy into the map
+ (*_proxy_map)[Salome_file_name] = proxy;
+ }
+ else {
+ this->wait_parallel_object_proxy();
+ }
+
+ proxy_ior = this->get_parallel_proxy_object();
+ (*_IOR_proxy_map)[Salome_file_name] = proxy_ior;
+
+ // We register each node of the parallel Salome_file object
+ // into the proxy.
+ for (int i = 0; i < getTotalNode(); i++) {
+ if (i == getMyRank()) {
+ Parallel_Salome_file_i * servant =
+ new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str());
+ PaCO_operation * servant_global_ptr = servant->getContext("global_paco_context");
+
+ // We initialize the object with the context of the Parallel component
+ PaCO_operation * compo_global_ptr = this->getContext("global_paco_context");
+// compo_global_ptr->init_context(servant_global_ptr);
+ servant_global_ptr->init_context(compo_global_ptr);
+
+ // We register the CORBA objet into the POA
+ servant->POA_PaCO::InterfaceParallel::_this();
+
+ // Register the servant
+ servant->deploy(getMyRank());
+
+ // Adding servant to the map
+ (*_map)[Salome_file_name] = servant;
+ }
+
+ PaCO_operation * compo_global_ptr = this->getContext("global_paco_context");
+ compo_global_ptr->my_com->paco_barrier();
+ }
+
+ // Parallel_Salome_file is created and deployed
+ delete _proxy;
+ _proxy = NULL;
+ }
+ pthread_mutex_unlock(deploy_mutex);
+ proxy_ior = (*_IOR_proxy_map)[Salome_file_name];
+ CORBA::Object_ptr proxy_ref = _orb->string_to_object(proxy_ior.c_str());
+ return Engines::Salome_file::_narrow(proxy_ref);
+}
+
+Engines::Salome_file_ptr
+Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we add it.
+ _Service_file_map_it = _Output_Service_file_map.find(service_name);
+ if (_Service_file_map_it == _Output_Service_file_map.end()) {
+ _t_Salome_file_map * _map = new _t_Salome_file_map();
+ _Output_Service_file_map[service_name] = _map;
+ _t_Proxy_Salome_file_map * _proxy_map = new _t_Proxy_Salome_file_map();
+ _Proxy_Output_Service_file_map[service_name] = _proxy_map;
+ _t_IOR_Proxy_Salome_file_map * _IOR_proxy_map = new _t_IOR_Proxy_Salome_file_map();
+ _IOR_Proxy_Output_Service_file_map[service_name] = _IOR_proxy_map;
+ }
+ _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+ _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Output_Service_file_map[service_name];
+ _t_IOR_Proxy_Salome_file_map * _IOR_proxy_map = _IOR_Proxy_Output_Service_file_map[service_name];
+
+ pthread_mutex_lock(deploy_mutex);
+ std::string proxy_ior;
+
+ // Try to find the Salome_file ...
+ _Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Salome_file_map_it == _map->end()) {
+
+ // We create a new PaCO++ object.
+ // He has the same configuration than
+ // his component
+
+ // Firstly, we have to create the proxy object
+ // of the Salome_file and transmit his
+ // reference to the other nodes.
+ if (getMyRank() == 0) {
+ Engines::Parallel_Salome_file_proxy_impl * proxy =
+ new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb));
+ PaCO_operation * proxy_global_ptr = proxy->getContext("global_paco_context");
+ // We initialize the object with the context of the Parallel component
+ PaCO_operation * compo_global_ptr = getContext("global_paco_context");
+ //compo_global_ptr->init_context(proxy_global_ptr);
+ proxy_global_ptr->init_context(compo_global_ptr);
+
+ paco_fabrique_manager* pfm = paco_getFabriqueManager();
+ pfm->register_com("dummy", new paco_dummy_fabrique());
+ proxy_global_ptr->setComFab(NULL);
+ proxy_global_ptr->setLibCom("dummy",NULL);
+
+ proxy_global_ptr->setTypeClient(true);
+ PaCO::PacoTopology_t client_topo;
+ client_topo.total = 1;
+ proxy_global_ptr->setClientTopo(client_topo);
+ PaCO::PacoTopology_t serveur_topo;
+ serveur_topo.total = getTotalNode();
+ proxy->setTopo(serveur_topo);
+
+ // We register the CORBA objet into the POA
+ CORBA::Object_ptr proxy_ref = proxy->_this();
+
+ // We send the reference to all the nodes...
+ CORBA::Object_ptr comp_proxy = _orb->string_to_object(_ior.c_str());
+ Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(comp_proxy);
+ component_proxy->send_parallel_proxy_object(proxy_ref);
+
+ // Adding proxy into the map
+ (*_proxy_map)[Salome_file_name] = proxy;
+ }
+ else {
+ this->wait_parallel_object_proxy();
+ }
+
+ proxy_ior = this->get_parallel_proxy_object();
+ (*_IOR_proxy_map)[Salome_file_name] = proxy_ior;
+
+ // We register each node of the parallel Salome_file object
+ // into the proxy.
+ for (int i = 0; i < getTotalNode(); i++) {
+ if (i == getMyRank()) {
+ Parallel_Salome_file_i * servant =
+ new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str());
+ PaCO_operation * servant_global_ptr = servant->getContext("global_paco_context");
+
+ // We initialize the object with the context of the Parallel component
+ PaCO_operation * compo_global_ptr = this->getContext("global_paco_context");
+// compo_global_ptr->init_context(servant_global_ptr);
+ servant_global_ptr->init_context(compo_global_ptr);
+
+ // We register the CORBA objet into the POA
+ servant->POA_PaCO::InterfaceParallel::_this();
+
+ // Register the servant
+ servant->deploy(getMyRank());
+
+ // Adding servant to the map
+ (*_map)[Salome_file_name] = servant;
+ }
+
+ PaCO_operation * compo_global_ptr = this->getContext("global_paco_context");
+ compo_global_ptr->my_com->paco_barrier();
+ }
+
+ // Parallel_Salome_file is created and deployed
+ delete _proxy;
+ _proxy = NULL;
+ }
+ pthread_mutex_unlock(deploy_mutex);
+ proxy_ior = (*_IOR_proxy_map)[Salome_file_name];
+ CORBA::Object_ptr proxy_ref = _orb->string_to_object(proxy_ior.c_str());
+ return Engines::Salome_file::_narrow(proxy_ref);
+}
+
+Engines::Salome_file_ptr
+Engines_Parallel_Component_i::getInputFileToService(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we throw an exception.
+ _Proxy_Service_file_map_it = _Proxy_Input_Service_file_map.find(service_name);
+ if (_Proxy_Service_file_map_it == _Proxy_Input_Service_file_map.end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have salome files";
+ throw SALOME::SALOME_Exception(es);
+ }
+ _t_Proxy_Salome_file_map * _map = _Proxy_Input_Service_file_map[service_name];
+
+ // Try to find the Salome_file ...
+ _Proxy_Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Proxy_Salome_file_map_it == _map->end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have this Salome_file";
+ throw SALOME::SALOME_Exception(es);
+ }
+
+ // Client get the proxy object
+ Engines::Parallel_Salome_file_proxy_impl * Sfile = (*_map)[Salome_file_name];
+ return Sfile->_this();
+}
+
+Engines::Salome_file_ptr
+Engines_Parallel_Component_i::getOutputFileToService(const char* service_name,
+ const char* Salome_file_name)
+{
+ // Try to find the service, if it doesn't exist, we throw an exception.
+ _Proxy_Service_file_map_it = _Proxy_Output_Service_file_map.find(service_name);
+ if (_Proxy_Service_file_map_it == _Proxy_Output_Service_file_map.end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have salome files";
+ throw SALOME::SALOME_Exception(es);
+ }
+ _t_Proxy_Salome_file_map * _map = _Proxy_Output_Service_file_map[service_name];
+
+ // Try to find the Salome_file ...
+ _Proxy_Salome_file_map_it = _map->find(Salome_file_name);
+ if (_Proxy_Salome_file_map_it == _map->end()) {
+ SALOME::ExceptionStruct es;
+ es.type = SALOME::INTERNAL_ERROR;
+ es.text = "service doesn't have this Salome_file";
+ throw SALOME::SALOME_Exception(es);
+ }
+
+ // Client get the proxy object
+ Engines::Parallel_Salome_file_proxy_impl * Sfile = (*_map)[Salome_file_name];
+ return Sfile->_this();
+}
+
+
+void
+Engines_Parallel_Component_i::checkInputFilesToService(const char* service_name)
+{
+ // Try to find the service, if it doesn't exist, nothing to do.
+ _Proxy_Service_file_map_it = _Proxy_Input_Service_file_map.find(service_name);
+ if (_Proxy_Service_file_map_it != _Proxy_Input_Service_file_map.end()) {
+ _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Input_Service_file_map[service_name];
+ _t_Proxy_Salome_file_map::iterator begin = _proxy_map->begin();
+ _t_Proxy_Salome_file_map::iterator end = _proxy_map->end();
+
+ for(;begin!=end;begin++) {
+ Engines::Parallel_Salome_file_proxy_impl * file = begin->second;
+ std::string file_port_name = begin->first;
+ configureSalome_file(service_name, file_port_name, file);
+ file->recvFiles();
+ }
+ }
+}
+
+void
+Engines_Parallel_Component_i::checkOutputFilesToService(const char* service_name)
+{
+ // Try to find the service, if it doesn't exist, nothing to do.
+ _Proxy_Service_file_map_it = _Proxy_Output_Service_file_map.find(service_name);
+ if (_Proxy_Service_file_map_it != _Proxy_Output_Service_file_map.end()) {
+ _t_Proxy_Salome_file_map * _map = _Proxy_Output_Service_file_map[service_name];
+ _t_Proxy_Salome_file_map::iterator begin = _map->begin();
+ _t_Proxy_Salome_file_map::iterator end = _map->end();
+
+ for(;begin!=end;begin++) {
+ Engines::Parallel_Salome_file_proxy_impl * file = begin->second;
+ std::string file_port_name = begin->first;
+ configureSalome_file(service_name, file_port_name, file);
+ file->recvFiles();
+ }
+ }
+
+}
+
+//=============================================================================
+/*!
+ * C++ method: Used by the Parallel Component to deploy a Parallel Salome_file
+ */
+//=============================================================================
+void
+Engines_Parallel_Component_i::send_parallel_proxy_object(CORBA::Object_ptr proxy_ref) {
+ _proxy = _orb->object_to_string(proxy_ref);
+}
+
+//=============================================================================
+/*!
+ * C++ method: Used by the Parallel Component to deploy a Parallel Salome_file
+ */
+//=============================================================================
+void
+Engines_Parallel_Component_i::wait_parallel_object_proxy() {
+ char * proxy = NULL;
+ proxy = get_parallel_proxy_object();
+ while(proxy == NULL)
+ {
+ sleep(1);
+ proxy = get_parallel_proxy_object();
+ }
+}
+
+//=============================================================================
+/*!
+ * C++ method: Used by the Parallel Component to deploy a Parallel Salome_file
+ */
+//=============================================================================
+char *
+Engines_Parallel_Component_i::get_parallel_proxy_object() {
+ return _proxy;
+}
+
+
+//=============================================================================
+/*!
+ * C++ method: used to configure the Salome_file into the runtime.
+ * \param service_name name of the service that use this Salome_file
+ * \param file_port_name name of the Salome_file
+ * \param file Parallel Salome_file C++ object
+ */
+//=============================================================================
+void
+Engines_Parallel_Component_i::configureSalome_file(std::string service_name,
+ std::string file_port_name,
+ Engines::Parallel_Salome_file_proxy_impl * file)
+{
+ // By default this method does nothing
+}
+
#include <map>
#include <SALOMEconfig.h>
-#include "SALOME_ComponentPaCO_Engines_Component_server.h"
+#include "SALOME_ComponentPaCO_Engines_Parallel_Component_server.h"
#include "NOTIFICATION.hxx"
#include "RegistryConnexion.hxx"
+#include "Parallel_Salome_file_i.hxx"
class Engines_Parallel_Container_i;
#endif
class CONTAINER_EXPORT Engines_Parallel_Component_i:
- public virtual Engines::Component_serv,
+ public virtual Engines::Parallel_Component_serv,
public virtual PortableServer::RefCountServantBase
{
public:
CORBA::Boolean isPublished,
CORBA::Boolean& isValidScript);
+ // CORBA operations for Salome_file
+ virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name,
+ const char* Salome_file_name);
+ virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name,
+ const char* Salome_file_name);
+
+ virtual void checkInputFilesToService(const char* service_name);
+ virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name,
+ const char* Salome_file_name);
+
+ virtual void checkOutputFilesToService(const char* service_name);
+ virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name,
+ const char* Salome_file_name);
+
+ void send_parallel_proxy_object(CORBA::Object_ptr proxy_ref);
// --- local C++ methods
void SetCurCpu() ;
long CpuUsed() ;
+ void wait_parallel_object_proxy();
+ char * get_parallel_proxy_object();
+
+ virtual void configureSalome_file(std::string service_name,
+ std::string file_port_name,
+ Engines::Parallel_Salome_file_proxy_impl * file);
+
protected:
int _studyId; // -1: not initialised; 0: multiStudy; >0: study
static bool _isMultiStudy;
NOTIFICATION_Supplier* _notifSupplier;
std::map<std::string,CORBA::Any>_fieldsDict;
+ // Map Salome_file_name to Parallel_Salome_file*
+ typedef std::map<std::string, Parallel_Salome_file_i*> _t_Salome_file_map;
+ typedef std::map<std::string, Engines::Parallel_Salome_file_proxy_impl*> _t_Proxy_Salome_file_map;
+ typedef std::map<std::string, std::string> _t_IOR_Proxy_Salome_file_map;
+
+ // Map Service_name to _Salome_file_map
+ typedef std::map<std::string, Engines_Parallel_Component_i::_t_Salome_file_map*> _t_Service_file_map;
+ typedef std::map<std::string, Engines_Parallel_Component_i::_t_Proxy_Salome_file_map*> _t_Proxy_Service_file_map;
+ typedef std::map<std::string, Engines_Parallel_Component_i::_t_IOR_Proxy_Salome_file_map*> _t_IOR_Proxy_Service_file_map;
+
+ _t_Service_file_map _Input_Service_file_map;
+ _t_Service_file_map _Output_Service_file_map;
+ _t_Service_file_map::iterator _Service_file_map_it;
+ _t_Salome_file_map::iterator _Salome_file_map_it;
+
+ _t_Proxy_Service_file_map _Proxy_Input_Service_file_map;
+ _t_Proxy_Service_file_map _Proxy_Output_Service_file_map;
+ _t_Proxy_Service_file_map::iterator _Proxy_Service_file_map_it;
+ _t_Proxy_Salome_file_map::iterator _Proxy_Salome_file_map_it;
+
+ _t_IOR_Proxy_Service_file_map _IOR_Proxy_Input_Service_file_map;
+ _t_IOR_Proxy_Service_file_map _IOR_Proxy_Output_Service_file_map;
+ _t_IOR_Proxy_Service_file_map::iterator _IOR_Proxy_Service_file_map_it;
+ _t_IOR_Proxy_Salome_file_map::iterator _IOR_Proxy_Salome_file_map_it;
+
std::string _serviceName ;
std::string _graphName ;
std::string _nodeName ;
+ pthread_mutex_t * deploy_mutex;
+ char * _proxy;
+
private:
#ifndef WNT
pthread_t _ThreadId ;
}
#endif
+typedef void (*sighandler_t)(int);
+sighandler_t setsig(int sig, sighandler_t handler)
+{
+ struct sigaction context, ocontext;
+ context.sa_handler = handler;
+ sigemptyset(&context.sa_mask);
+ context.sa_flags = 0;
+ if (sigaction(sig, &context, &ocontext) == -1)
+ return SIG_ERR;
+ return ocontext.sa_handler;
+}
+
+void AttachDebugger()
+{
+ if(getenv ("DEBUGGER"))
+ {
+ std::stringstream exec;
+ exec << "$DEBUGGER SALOME_ParallelContainerNodeDummy " << getpid() << "&";
+ std::cerr << exec.str() << std::endl;
+ system(exec.str().c_str());
+ while(1);
+ }
+}
+
+void Handler(int theSigId)
+{
+ std::cerr << "SIGSEGV: " << std::endl;
+ AttachDebugger();
+ //to exit or not to exit
+ exit(1);
+}
+
+void terminateHandler(void)
+{
+ std::cerr << "Terminate: not managed exception !" << std::endl;
+ AttachDebugger();
+}
+
+void unexpectedHandler(void)
+{
+ std::cerr << "Unexpected: unexpected exception !" << std::endl;
+ AttachDebugger();
+}
+
int main(int argc, char* argv[])
{
INFOS("Launching a parallel container node");
#ifdef _DEBUG_
- signal(SIGSEGV, handler);
+// signal(SIGSEGV, handler);
#endif
+ if(getenv ("DEBUGGER"))
+ {
+ setsig(SIGSEGV,&Handler);
+ set_terminate(&terminateHandler);
+ set_unexpected(&unexpectedHandler);
+ }
// Initialise the ORB.
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
using namespace std;
-#ifdef DEBUG_PARALLEL
+#ifdef _DEBUG_
#include <signal.h>
+void test(int sigval) {
+ cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+ cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+ cerr << "SIGSEGV in :" << getpid() << endl;
+ cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+ cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+ while (1) {}
+}
+
void handler(int t) {
cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
}
#endif
+typedef void (*sighandler_t)(int);
+sighandler_t setsig(int sig, sighandler_t handler)
+{
+ struct sigaction context, ocontext;
+ context.sa_handler = handler;
+ sigemptyset(&context.sa_mask);
+ context.sa_flags = 0;
+ if (sigaction(sig, &context, &ocontext) == -1)
+ return SIG_ERR;
+ return ocontext.sa_handler;
+}
+
+void AttachDebugger()
+{
+ if(getenv ("DEBUGGER"))
+ {
+ std::stringstream exec;
+ exec << "$DEBUGGER SALOME_ParallelContainerNodeMpi " << getpid() << "&";
+ std::cerr << exec.str() << std::endl;
+ system(exec.str().c_str());
+ while(1);
+ }
+}
+
+void Handler(int theSigId)
+{
+ std::cerr << "SIGSEGV: " << std::endl;
+ AttachDebugger();
+ //to exit or not to exit
+ exit(1);
+}
+
+void terminateHandler(void)
+{
+ std::cerr << "Terminate: not managed exception !" << std::endl;
+ AttachDebugger();
+}
+
+void unexpectedHandler(void)
+{
+ std::cerr << "Unexpected: unexpected exception !" << std::endl;
+ AttachDebugger();
+}
+
int main(int argc, char* argv[])
{
INFOS("Launching a parallel Mpi container node");
-#ifdef DEBUG_PARALLEL
- signal(SIGSEGV, handler);
+#ifdef _DEBUG_
+// struct sigaction action;
+// action.sa_handler = &test;
+// sigaction(SIGSEGV, &action, NULL);
#endif
// MPI Init
int provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE ,&provided);
-#ifdef DEBUG_PARALLEL
+ if(getenv ("DEBUGGER"))
+ {
+ std::cerr << "Unexpected: unexpected exception !" << std::endl;
+ setsig(SIGSEGV,&Handler);
+ set_terminate(&terminateHandler);
+ set_unexpected(&unexpectedHandler);
+ }
+#ifdef _DEBUG_
cerr << "Level MPI_THREAD_SINGLE : " << MPI_THREAD_SINGLE << endl;
cerr << "Level MPI_THREAD_SERIALIZED : " << MPI_THREAD_SERIALIZED << endl;
cerr << "Level MPI_THREAD_FUNNELED : " << MPI_THREAD_FUNNELED << endl;
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
// File : SALOME_ParallelContainer_i.cxx
-// Author : André RIBES, EDF
+// Author : Andr� RIBES, EDF
// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
#include <SALOMEconfig.h>
// in the nameing service.
_numInstanceMutex.lock() ; // lock on the instance number
_numInstance++ ;
- int numInstance = _numInstance ;
+// int numInstance = _numInstance ;
_numInstanceMutex.unlock() ;
}
cerr << "Node " << getMyRank() << " entering in paco_barrier()" << endl;
}
+Engines::Salome_file_ptr
+Engines_Parallel_Container_i::createSalome_file(const char* origFileName)
+{
+ string origName(origFileName);
+ if (CORBA::is_nil(_Salome_file_map[origName]))
+ {
+ Salome_file_i* aSalome_file = new Salome_file_i();
+ try
+ {
+ aSalome_file->setLocalFile(origFileName);
+ aSalome_file->recvFiles();
+ }
+ catch (const SALOME::SALOME_Exception& e)
+ {
+ return Engines::Salome_file::_nil();
+ }
+
+ Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil();
+ theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this());
+ _numInstanceMutex.lock() ; // lock to be alone (stl container write)
+ _Salome_file_map[origName] = theSalome_file;
+ _numInstanceMutex.unlock() ;
+ }
+
+ Engines::Salome_file_ptr theSalome_file =
+ Engines::Salome_file::_duplicate(_Salome_file_map[origName]);
+ ASSERT(!CORBA::is_nil(theSalome_file));
+ return theSalome_file;
+}
Engines::fileRef_ptr createFileRef(const char* origFileName);
Engines::fileTransfer_ptr getFileTransfer();
+
+ virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
protected:
static std::map<std::string, int> _cntInstances_map;
int _numInstance ;
std::map<std::string,Engines::Component_var> _listInstances_map;
std::map<std::string,Engines::fileRef_var> _fileRef_map;
+ std::map<std::string,Engines::Salome_file_var> _Salome_file_map;
Engines::fileTransfer_var _fileTransfer;
int _argc ;
#define REGISTRY_EXPORT
#endif
-#endif
\ No newline at end of file
+#endif
+
if (par < 0)
{
// Nodes case
+
command = "mpiexec -np " + string(buffer) + " ";
+// command += "gdb --args ";
command += real_exe_name;
command += " " + _NS->ContainerName(rtn);
command += " " + parallelLib;
if (log == "xterm")
{
command = "/usr/X11R6/bin/xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH; "
- + command + " \" &";
- //command = "/usr/X11R6/bin/xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH; "
- // + command + "; cat \" &";
+ + command + " \" &";
+// + command + "; echo $LD_LIBRARY_PATH; cat \" &";
}
return command;
import sys, os,signal,string,commands
import runSalome
+import setenv
import orbmodule
import TestKiller
# get SALOME environment :
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
# launch CORBA naming server
import sys, os,signal,string,commands
import runSalome
+import setenv
# get SALOME environment :
# here we need KERNEL_ROOT_DIR, PATH, LD_LIBRARY_PATH
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
# execute Unit Test
import sys, os,signal,string,commands
import runSalome
+import setenv
import orbmodule
import TestKiller
# get SALOME environment :
-args, modules_list, modules_root_dir = runSalome.get_config()
-runSalome.set_env(args, modules_list, modules_root_dir)
+args, modules_list, modules_root_dir = setenv.get_config()
+setenv.set_env(args, modules_list, modules_root_dir)
# set environment for trace in logger
# (with file, servers may be killed before the write to the file...)