Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / yacsorb / CORBAEngineTest.py
1 #  Copyright (C) 2006-2008  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.
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 import time
20
21 import salome
22 salome.salome_init()
23
24 import YACS_ORB
25 comp = salome.lcc.FindOrLoadComponent( "YACSContainer","YACS" )
26 yacsgen = comp._narrow(YACS_ORB.YACS_Gen)
27
28 # -----------------------------------------------------------------------------
29 # --- schema OK
30
31 procEx = yacsgen.LoadProc("samples/legendre7.xml")
32 procEx.setExecMode(YACS_ORB.CONTINUE)
33 procEx.Run()
34
35 # --- wait until executor is paused, finished or stopped
36
37 isRunning = 1
38 while isRunning:
39     time.sleep(0.5)
40     state = procEx.getExecutorState()
41     isRunning = (state < 304)
42     print "executorState: ", state
43     pass
44
45 procEx.saveState("res.xml")
46 numids,names = procEx.getIds()
47
48 dico = {}
49 i=0
50 for name in names:
51     dico[name] = numids[i]
52     i+=1
53     pass
54
55 print procEx.getOutPortValue(dico["poly_7"],"Pn")
56 print procEx.getInPortValue(dico["poly_7"],"x")
57 print procEx.getInPortValue(dico["poly_7"],"notAPort")
58 print procEx.getInPortValue(dico["Legendre.loopIter"],"nsteps")
59
60 # -----------------------------------------------------------------------------
61 # --- schema with errors (echoSrv must be launched)
62
63 procEx = yacsgen.LoadProc("samples/aschema.xml")
64 procEx.setExecMode(YACS_ORB.CONTINUE)
65 procEx.Run()
66
67 # --- wait until executor is paused, finised or stopped
68
69 isRunning = 1
70 while isRunning:
71     time.sleep(0.5)
72     state = procEx.getExecutorState()
73     isRunning = (state < 304)
74     print "executorState: ", state
75     pass
76
77 procEx.saveState("res2.xml")
78 numids,names = procEx.getIds()
79
80 dico = {}
81 i=0
82 for name in names:
83     dico[name] = numids[i]
84     i+=1
85     pass
86
87 print procEx.getErrorDetails(dico["c1"])
88 print procEx.getErrorDetails(dico["node13"])
89
90 # -----------------------------------------------------------------------------
91 # --- schema with errors
92
93 procEx = yacsgen.LoadProc("samples/triangle5error.xml")
94 procEx.setExecMode(YACS_ORB.CONTINUE)
95 procEx.setStopOnError(1,"execError2.xml")
96 #procEx.unsetStopOnError()
97 procEx.Run()
98
99 isRunning = 1
100 while isRunning:
101     time.sleep(0.5)
102     state = procEx.getExecutorState()
103     isRunning = (state < 304)
104     print "executorState: ", state
105     pass
106
107 #procEx.resumeCurrentBreakPoint()
108
109 procEx.saveState("res3.xml")
110
111 # -----------------------------------------------------------------------------
112 # --- schema with breakpoints
113
114 procEx = yacsgen.LoadProc("samples/legendre7.xml")
115 procEx.setListOfBreakPoints(["Legendre.loopIter.deuxIter.iter2"])
116 procEx.setExecMode(YACS_ORB.STOPBEFORENODES)
117 procEx.Run()
118
119 isRunning = 1
120 while isRunning:
121     time.sleep(0.5)
122     state = procEx.getExecutorState()
123     isRunning = (state < 304)
124     print "executorState: ", state
125     pass
126
127 procEx.saveState("partialExec.xml")
128
129 procEx = yacsgen.LoadProc("samples/legendre7.xml")
130 procEx.setExecMode(YACS_ORB.CONTINUE)
131 procEx.RunFromState("partialExec.xml")
132
133 isRunning = 1
134 while isRunning:
135     time.sleep(0.5)
136     state = procEx.getExecutorState()
137     isRunning = (state < 304)
138     print "executorState: ", state
139     pass
140
141 procEx.saveState("finishExec.xml")
142