1 # Copyright (C) 2007-2015 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, or (at your option) any later version.
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
23 # Generated python file of Graph GraphCpuUsed
28 GraphCpuUsed = Graph( 'GraphCpuUsed' )
29 GraphCpuUsed.SetName( 'GraphCpuUsed' )
30 GraphCpuUsed.SetAuthor( '' )
31 GraphCpuUsed.SetComment( '' )
32 GraphCpuUsed.Coords( 0 , 0 )
34 # Creation of Factory Nodes
36 sigma = GraphCpuUsed.FNode( 'FactorialComponent' , 'FactorialComponent' , 'sigma' )
37 sigma.SetName( 'sigma' )
38 sigma.SetAuthor( 'JR' )
39 sigma.SetContainer( 'localhost/FactoryServerPy' )
40 sigma.SetComment( 'sigma from FactorialComponent' )
41 sigma.Coords( 214 , 172 )
43 Sigma = GraphCpuUsed.FNode( 'AddComponent' , 'AddComponent' , 'Sigma' )
44 Sigma.SetName( 'Sigma' )
46 Sigma.SetContainer( 'localhost/FactoryServer' )
47 Sigma.SetComment( 'Sigma from AddComponent' )
48 Sigma.Coords( 418 , 21 )
50 # Creation of InLine Nodes
52 PyAdd.append( 'from time import * ' )
53 PyAdd.append( 'def Add(a,b) : ' )
54 PyAdd.append( ' print "Add will wait 5 seconds" ' )
55 PyAdd.append( ' d = dir() ' )
56 PyAdd.append( ' print "Add",d ' )
57 PyAdd.append( ' d = dir(sleep) ' )
58 PyAdd.append( ' print "Add",d ' )
59 PyAdd.append( ' sleep(5) ' )
60 PyAdd.append( ' print "Add waited" ' )
61 PyAdd.append( ' n = 0 ' )
62 PyAdd.append( ' while n < 10000 : ' )
63 PyAdd.append( ' i = 0 ' )
64 PyAdd.append( ' s = 0 ' )
65 PyAdd.append( ' while i <= b : ' )
66 PyAdd.append( ' s = s + i ' )
67 PyAdd.append( ' i = i + 1 ' )
68 PyAdd.append( ' n = n + 1 ' )
69 PyAdd.append( ' return s ' )
71 Add = GraphCpuUsed.INode( 'Add' , PyAdd )
72 Add.InPort( 'a' , 'long' )
73 Add.InPort( 'b' , 'long' )
74 Add.OutPort( 'f' , 'long' )
77 Add.SetComment( 'Python function' )
81 PySub.append( 'def Sub(a,b) : ' )
82 PySub.append( ' return a-b ' )
84 Sub = GraphCpuUsed.INode( 'Sub' , PySub )
85 Sub.InPort( 'a' , 'long' )
86 Sub.InPort( 'b' , 'long' )
87 Sub.OutPort( 'f' , 'long' )
90 Sub.SetComment( 'Python function' )
94 PyCompare.append( 'def Compare( Add , sigma , Sigma ) : ' )
95 PyCompare.append( ' Result = "Good" ' )
96 PyCompare.append( ' if Add != sigma : ' )
97 PyCompare.append( ' Result = "Bad" ' )
98 PyCompare.append( ' if Add != Sigma : ' )
99 PyCompare.append( ' Result = "Bad" ' )
100 PyCompare.append( ' return Result ' )
101 PyCompare.append( '' )
102 Compare = GraphCpuUsed.INode( 'Compare' , PyCompare )
103 Compare.InPort( 'Add' , 'long' )
104 Compare.InPort( 'Sigma' , 'long' )
105 Compare.InPort( 'sigma' , 'long' )
106 Compare.OutPort( 'Result' , 'string' )
107 Compare.SetName( 'Compare' )
108 Compare.SetAuthor( '' )
109 Compare.SetComment( 'Compute Node' )
110 Compare.Coords( 419 , 184 )
113 Addf = Add.Port( 'f' )
114 CompareAdd = GraphCpuUsed.Link( Addf , Compare.Port( 'Add' ) )
115 CompareAdd.AddCoord( 1 , 411 , 265 )
116 CompareAdd.AddCoord( 2 , 411 , 169 )
117 CompareAdd.AddCoord( 3 , 617 , 169 )
118 CompareAdd.AddCoord( 4 , 618 , 8 )
119 CompareAdd.AddCoord( 5 , 401 , 8 )
120 CompareAdd.AddCoord( 6 , 400 , 80 )
122 Subf = Sub.Port( 'f' )
123 Addb = GraphCpuUsed.Link( Subf , Add.Port( 'b' ) )
124 Addb.AddCoord( 1 , 189 , 108 )
125 Addb.AddCoord( 2 , 191 , 220 )
127 sigman = GraphCpuUsed.Link( Subf , sigma.Port( 'n' ) )
128 sigman.AddCoord( 1 , 206 , 254 )
129 sigman.AddCoord( 2 , 206 , 220 )
131 Sigman = GraphCpuUsed.Link( Subf , Sigma.Port( 'n' ) )
132 Sigman.AddCoord( 1 , 389 , 101 )
133 Sigman.AddCoord( 2 , 390 , 160 )
134 Sigman.AddCoord( 3 , 190 , 161 )
135 Sigman.AddCoord( 4 , 190 , 220 )
137 sigmaf = sigma.Port( 'f' )
138 Comparesigma = GraphCpuUsed.Link( sigmaf , Compare.Port( 'sigma' ) )
139 Comparesigma.AddCoord( 1 , 386 , 323 )
140 Comparesigma.AddCoord( 2 , 385 , 253 )
142 Sigmaf = Sigma.Port( 'f' )
143 CompareSigma = GraphCpuUsed.Link( Sigmaf , Compare.Port( 'Sigma' ) )
144 CompareSigma.AddCoord( 1 , 400 , 295 )
145 CompareSigma.AddCoord( 2 , 400 , 153 )
146 CompareSigma.AddCoord( 3 , 595 , 153 )
147 CompareSigma.AddCoord( 4 , 595 , 102 )
149 # Creation of Input datas
150 Adda = Add.Input( 'a' , 1)
151 Suba = Sub.Input( 'a' , 1000)
152 Subb = Sub.Input( 'b' , 1)
154 # Creation of Output variables
155 CompareResult = Compare.Port( 'Result' )
158 while GraphCpuUsed.IsDone() == 0 :
160 print "sigma",sigma.CpuUsed(),"seconds"
161 print "Sigma",Sigma.CpuUsed(),"seconds"
162 print "Add",Add.CpuUsed(),"seconds"
163 print "Sub",Sub.CpuUsed(),"seconds"
164 print "Compare",Compare.CpuUsed(),"seconds"
166 print GraphCpuUsed.State()
167 GraphCpuUsed.PrintPorts()
168 print "sigma",sigma.CpuUsed(),"seconds"
169 print "Sigma",Sigma.CpuUsed(),"seconds"
170 print "Add",Add.CpuUsed(),"seconds"
171 print "Sub",Sub.CpuUsed(),"seconds"
172 print "Compare",Compare.CpuUsed(),"seconds"