Salome HOME
Bug correction EDF12462 (1)
[modules/yacs.git] / src / evalyfx_swig / test1.py
1 # bug revealed by otgui on 8/2/16. Several lock/unlock session. test1.xml is Cogeneration.xml.
2
3 def buildScheme(fname):
4     import SALOMERuntime
5     import loader
6     SALOMERuntime.RuntimeSALOME.setRuntime()
7     r=SALOMERuntime.getSALOMERuntime()
8     p=r.createProc("run")
9     cont=p.createContainer("MyWonderfulContainer","Salome")
10     td=p.createType("double","double")
11     n0=r.createScriptNode("Salome","PyScript0")
12     p.edAddChild(n0)
13     q=n0.edAddInputPort("q",td)
14     e=n0.edAddInputPort("e",td)
15     c=n0.edAddInputPort("c",td)
16     ep=n0.edAddOutputPort("ep",td)
17     n0.setScript("ep=1-(q/((e/((1-0.05)*0.54))+(c/0.8)))")
18     n0.setExecutionMode("remote")
19     n0.setContainer(cont)
20     p.saveSchema(fname)
21     pass
22
23 fname="test1.xml"
24 import evalyfx
25 session=evalyfx.YACSEvalSession()
26 session.launch()
27 buildScheme(fname)
28 efx=evalyfx.YACSEvalYFX.BuildFromFile(fname)
29 efx.setParallelizeStatus(False)
30 inps=efx.getFreeInputPorts()
31 outps=efx.getFreeOutputPorts()
32 for inp in inps:
33     inp.setSequenceOfValuesToEval([0.2,0.3])
34 efx.lockPortsForEvaluation(inps,outps)
35 rss=efx.giveResources()
36 rss[0][0].setWantedMachine("localhost")
37 a,b=efx.run(session) ; assert(a)
38 efx.unlockAll()
39 for ii,inp in enumerate(inps):
40     inp.setSequenceOfValuesToEval([0.5,0.6,0.7])
41 efx.lockPortsForEvaluation(inps,outps)
42 a,b=efx.run(session) ; assert(a)
43 efx.unlockAll()
44 for ii,inp in enumerate(inps):
45     inp.setSequenceOfValuesToEval([0.5,0.6,0.7])
46 efx.lockPortsForEvaluation(inps,outps)
47 a,b=efx.run(session) ; assert(a)