1 # Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Generated python file of Graph GraphCpuUsed
27 GraphCpuUsed = Graph( 'GraphCpuUsed' )
28 GraphCpuUsed.SetName( 'GraphCpuUsed' )
29 GraphCpuUsed.SetAuthor( '' )
30 GraphCpuUsed.SetComment( '' )
31 GraphCpuUsed.Coords( 0 , 0 )
33 # Creation of Factory Nodes
35 sigma = GraphCpuUsed.FNode( 'FactorialComponent' , 'FactorialComponent' , 'sigma' )
36 sigma.SetName( 'sigma' )
37 sigma.SetAuthor( 'JR' )
38 sigma.SetContainer( 'localhost/FactoryServerPy' )
39 sigma.SetComment( 'sigma from FactorialComponent' )
40 sigma.Coords( 214 , 172 )
42 Sigma = GraphCpuUsed.FNode( 'AddComponent' , 'AddComponent' , 'Sigma' )
43 Sigma.SetName( 'Sigma' )
45 Sigma.SetContainer( 'localhost/FactoryServer' )
46 Sigma.SetComment( 'Sigma from AddComponent' )
47 Sigma.Coords( 418 , 21 )
49 # Creation of InLine Nodes
51 PyAdd.append( 'from time import * ' )
52 PyAdd.append( 'def Add(a,b) : ' )
53 PyAdd.append( ' print "Add will wait 5 seconds" ' )
54 PyAdd.append( ' d = dir() ' )
55 PyAdd.append( ' print "Add",d ' )
56 PyAdd.append( ' d = dir(sleep) ' )
57 PyAdd.append( ' print "Add",d ' )
58 PyAdd.append( ' sleep(5) ' )
59 PyAdd.append( ' print "Add waited" ' )
60 PyAdd.append( ' n = 0 ' )
61 PyAdd.append( ' while n < 10000 : ' )
62 PyAdd.append( ' i = 0 ' )
63 PyAdd.append( ' s = 0 ' )
64 PyAdd.append( ' while i <= b : ' )
65 PyAdd.append( ' s = s + i ' )
66 PyAdd.append( ' i = i + 1 ' )
67 PyAdd.append( ' n = n + 1 ' )
68 PyAdd.append( ' return s ' )
70 Add = GraphCpuUsed.INode( 'Add' , PyAdd )
71 Add.InPort( 'a' , 'long' )
72 Add.InPort( 'b' , 'long' )
73 Add.OutPort( 'f' , 'long' )
76 Add.SetComment( 'Python function' )
80 PySub.append( 'def Sub(a,b) : ' )
81 PySub.append( ' return a-b ' )
83 Sub = GraphCpuUsed.INode( 'Sub' , PySub )
84 Sub.InPort( 'a' , 'long' )
85 Sub.InPort( 'b' , 'long' )
86 Sub.OutPort( 'f' , 'long' )
89 Sub.SetComment( 'Python function' )
93 PyCompare.append( 'def Compare( Add , sigma , Sigma ) : ' )
94 PyCompare.append( ' Result = "Good" ' )
95 PyCompare.append( ' if Add != sigma : ' )
96 PyCompare.append( ' Result = "Bad" ' )
97 PyCompare.append( ' if Add != Sigma : ' )
98 PyCompare.append( ' Result = "Bad" ' )
99 PyCompare.append( ' return Result ' )
100 PyCompare.append( '' )
101 Compare = GraphCpuUsed.INode( 'Compare' , PyCompare )
102 Compare.InPort( 'Add' , 'long' )
103 Compare.InPort( 'Sigma' , 'long' )
104 Compare.InPort( 'sigma' , 'long' )
105 Compare.OutPort( 'Result' , 'string' )
106 Compare.SetName( 'Compare' )
107 Compare.SetAuthor( '' )
108 Compare.SetComment( 'Compute Node' )
109 Compare.Coords( 419 , 184 )
112 Addf = Add.Port( 'f' )
113 CompareAdd = GraphCpuUsed.Link( Addf , Compare.Port( 'Add' ) )
114 CompareAdd.AddCoord( 1 , 411 , 265 )
115 CompareAdd.AddCoord( 2 , 411 , 169 )
116 CompareAdd.AddCoord( 3 , 617 , 169 )
117 CompareAdd.AddCoord( 4 , 618 , 8 )
118 CompareAdd.AddCoord( 5 , 401 , 8 )
119 CompareAdd.AddCoord( 6 , 400 , 80 )
121 Subf = Sub.Port( 'f' )
122 Addb = GraphCpuUsed.Link( Subf , Add.Port( 'b' ) )
123 Addb.AddCoord( 1 , 189 , 108 )
124 Addb.AddCoord( 2 , 191 , 220 )
126 sigman = GraphCpuUsed.Link( Subf , sigma.Port( 'n' ) )
127 sigman.AddCoord( 1 , 206 , 254 )
128 sigman.AddCoord( 2 , 206 , 220 )
130 Sigman = GraphCpuUsed.Link( Subf , Sigma.Port( 'n' ) )
131 Sigman.AddCoord( 1 , 389 , 101 )
132 Sigman.AddCoord( 2 , 390 , 160 )
133 Sigman.AddCoord( 3 , 190 , 161 )
134 Sigman.AddCoord( 4 , 190 , 220 )
136 sigmaf = sigma.Port( 'f' )
137 Comparesigma = GraphCpuUsed.Link( sigmaf , Compare.Port( 'sigma' ) )
138 Comparesigma.AddCoord( 1 , 386 , 323 )
139 Comparesigma.AddCoord( 2 , 385 , 253 )
141 Sigmaf = Sigma.Port( 'f' )
142 CompareSigma = GraphCpuUsed.Link( Sigmaf , Compare.Port( 'Sigma' ) )
143 CompareSigma.AddCoord( 1 , 400 , 295 )
144 CompareSigma.AddCoord( 2 , 400 , 153 )
145 CompareSigma.AddCoord( 3 , 595 , 153 )
146 CompareSigma.AddCoord( 4 , 595 , 102 )
148 # Creation of Input datas
149 Adda = Add.Input( 'a' , 1)
150 Suba = Sub.Input( 'a' , 1000)
151 Subb = Sub.Input( 'b' , 1)
153 # Creation of Output variables
154 CompareResult = Compare.Port( 'Result' )
157 while GraphCpuUsed.IsDone() == 0 :
159 print "sigma",sigma.CpuUsed(),"seconds"
160 print "Sigma",Sigma.CpuUsed(),"seconds"
161 print "Add",Add.CpuUsed(),"seconds"
162 print "Sub",Sub.CpuUsed(),"seconds"
163 print "Compare",Compare.CpuUsed(),"seconds"
165 print GraphCpuUsed.State()
166 GraphCpuUsed.PrintPorts()
167 print "sigma",sigma.CpuUsed(),"seconds"
168 print "Sigma",Sigma.CpuUsed(),"seconds"
169 print "Add",Add.CpuUsed(),"seconds"
170 print "Sub",Sub.CpuUsed(),"seconds"
171 print "Compare",Compare.CpuUsed(),"seconds"