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