Salome HOME
203fe5e23a6abd7cb5310b8af4c7d7e965efea0f
[modules/yacs.git] / src / evalyfx_swig / test1.py
1 # Copyright (C) 2015-2023  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # bug revealed by otgui on 8/2/16. Several lock/unlock session. test1.xml is Cogeneration.xml.
21
22 def buildScheme(fname):
23     import SALOMERuntime
24     import loader
25     SALOMERuntime.RuntimeSALOME.setRuntime()
26     r=SALOMERuntime.getSALOMERuntime()
27     p=r.createProc("run")
28     cont=p.createContainer("MyWonderfulContainer","Salome")
29     td=p.createType("double","double")
30     n0=r.createScriptNode("Salome","PyScript0")
31     p.edAddChild(n0)
32     q=n0.edAddInputPort("q",td)
33     e=n0.edAddInputPort("e",td)
34     c=n0.edAddInputPort("c",td)
35     ep=n0.edAddOutputPort("ep",td)
36     n0.setScript("ep=1-(q/((e/((1-0.05)*0.54))+(c/0.8)))")
37     n0.setExecutionMode("remote")
38     n0.setContainer(cont)
39     p.saveSchema(fname)
40     pass
41
42 fname="test1.xml"
43 import evalyfx
44 session=evalyfx.YACSEvalSession()
45 session.launch()
46 buildScheme(fname)
47 efx=evalyfx.YACSEvalYFX.BuildFromFile(fname)
48 efx.setParallelizeStatus(False)
49 inps=efx.getFreeInputPorts()
50 outps=efx.getFreeOutputPorts()
51 for inp in inps:
52     inp.setSequenceOfValuesToEval([0.2,0.3])
53 efx.lockPortsForEvaluation(inps,outps)
54 rss=efx.giveResources()
55 rss[0][0].setWantedMachine("localhost")
56 assert(rss.isInteractive())
57 a,b=efx.run(session) ; assert(a)
58 efx.unlockAll()
59 for ii,inp in enumerate(inps):
60     inp.setSequenceOfValuesToEval([0.5,0.6,0.7])
61 efx.lockPortsForEvaluation(inps,outps)
62 a,b=efx.run(session) ; assert(a)
63 efx.unlockAll()
64 for ii,inp in enumerate(inps):
65     inp.setSequenceOfValuesToEval([0.5,0.6,0.7])
66 efx.lockPortsForEvaluation(inps,outps)
67 a,b=efx.run(session) ; assert(a)