1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2011-2012 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author(s): Guillaume Boulant (23/03/2011)
23 # This script illustrates the standard use case of the component
24 # MeshJobManager from within a SALOME script.
28 # Preparing the configuration parameters
31 from salome.smesh.spadder.configreader import ConfigReader, printConfig
33 configReader = ConfigReader()
34 defaultConfig = configReader.getDefaultConfig()
35 printConfig(defaultConfig)
37 from salome.smesh import spadder
38 file_concrete=os.path.join(spadder.getTestDataDir(),"concrete.med")
39 file_steelbar=os.path.join(spadder.getTestDataDir(),"ferraill.med")
45 # Setup the configuration in the component. When first have to load
46 # the catalog of SPADDER components, then load the component
47 # MeshJobManager, and finally configure this component.
49 spadder.loadSpadderCatalog()
52 component = salome.lcc.FindOrLoadComponent("FactoryServer","MeshJobManager")
53 config = MESHJOB.ConfigParameter(resname=defaultConfig.resname,
54 binpath=defaultConfig.binpath,
55 envpath=defaultConfig.envpath)
56 component.configure("localhost",config)
59 # Prepare the job parameters and initialize the job
61 meshJobParameterList = []
62 param = MESHJOB.MeshJobParameter(file_name=file_concrete,
63 file_type=MESHJOB.MED_CONCRETE,
64 group_name="concrete")
65 meshJobParameterList.append(param)
67 param = MESHJOB.MeshJobParameter(file_name=file_steelbar,
68 file_type=MESHJOB.MED_STEELBAR,
69 group_name="steelbar")
70 meshJobParameterList.append(param)
71 jobid = component.initialize(meshJobParameterList, "localhost")
74 # Start the execution of the job identified by its job id.
76 ok=component.start(jobid)
79 # This part illustrates how you can follow the execution of the job.
81 run_states = ["CREATED", "IN_PROCESS", "QUEUED", "RUNNING", "PAUSED"];
82 end_states = ["FINISHED", "ERROR"]
83 all_states = run_states+end_states;
89 state = component.getState(jobid)
90 print "MeshJobManager ["+str(nbiter)+"] : state = "+str(state)
91 if state not in run_states:
96 if state not in end_states:
97 print "ERR: jobid = "+str(jobid)+" ended abnormally with state="+str(state)
99 print "OK: jobid = "+str(jobid)+" ended with state="+str(state)
100 meshJobResults = component.finalize(jobid)
102 print "You will find the results files in the directory:\n%s"%meshJobResults.results_dirname