2 # Generated python file of Graph GraphCpuUsed
7 GraphCpuUsed = Graph( 'GraphCpuUsed' )
8 GraphCpuUsed.SetName( 'GraphCpuUsed' )
9 GraphCpuUsed.SetAuthor( '' )
10 GraphCpuUsed.SetComment( '' )
11 GraphCpuUsed.Coords( 0 , 0 )
13 # Creation of Factory Nodes
15 sigma = GraphCpuUsed.FNode( 'FactorialComponent' , 'FactorialComponent' , 'sigma' )
16 sigma.SetName( 'sigma' )
17 sigma.SetAuthor( 'JR' )
18 sigma.SetContainer( 'localhost/FactoryServerPy' )
19 sigma.SetComment( 'sigma from FactorialComponent' )
20 sigma.Coords( 214 , 172 )
22 Sigma = GraphCpuUsed.FNode( 'AddComponent' , 'AddComponent' , 'Sigma' )
23 Sigma.SetName( 'Sigma' )
25 Sigma.SetContainer( 'localhost/FactoryServer' )
26 Sigma.SetComment( 'Sigma from AddComponent' )
27 Sigma.Coords( 418 , 21 )
29 # Creation of InLine Nodes
31 PyAdd.append( 'from time import * ' )
32 PyAdd.append( 'def Add(a,b) : ' )
33 PyAdd.append( ' print "Add will wait 5 seconds" ' )
34 PyAdd.append( ' d = dir() ' )
35 PyAdd.append( ' print "Add",d ' )
36 PyAdd.append( ' d = dir(sleep) ' )
37 PyAdd.append( ' print "Add",d ' )
38 PyAdd.append( ' sleep(5) ' )
39 PyAdd.append( ' print "Add waited" ' )
40 PyAdd.append( ' n = 0 ' )
41 PyAdd.append( ' while n < 10000 : ' )
42 PyAdd.append( ' i = 0 ' )
43 PyAdd.append( ' s = 0 ' )
44 PyAdd.append( ' while i <= b : ' )
45 PyAdd.append( ' s = s + i ' )
46 PyAdd.append( ' i = i + 1 ' )
47 PyAdd.append( ' n = n + 1 ' )
48 PyAdd.append( ' return s ' )
50 Add = GraphCpuUsed.INode( 'Add' , PyAdd )
51 Add.InPort( 'a' , 'long' )
52 Add.InPort( 'b' , 'long' )
53 Add.OutPort( 'f' , 'long' )
56 Add.SetComment( 'Python function' )
60 PySub.append( 'def Sub(a,b) : ' )
61 PySub.append( ' return a-b ' )
63 Sub = GraphCpuUsed.INode( 'Sub' , PySub )
64 Sub.InPort( 'a' , 'long' )
65 Sub.InPort( 'b' , 'long' )
66 Sub.OutPort( 'f' , 'long' )
69 Sub.SetComment( 'Python function' )
73 PyCompare.append( 'def Compare( Add , sigma , Sigma ) : ' )
74 PyCompare.append( ' Result = "Good" ' )
75 PyCompare.append( ' if Add != sigma : ' )
76 PyCompare.append( ' Result = "Bad" ' )
77 PyCompare.append( ' if Add != Sigma : ' )
78 PyCompare.append( ' Result = "Bad" ' )
79 PyCompare.append( ' return Result ' )
80 PyCompare.append( '' )
81 Compare = GraphCpuUsed.INode( 'Compare' , PyCompare )
82 Compare.InPort( 'Add' , 'long' )
83 Compare.InPort( 'Sigma' , 'long' )
84 Compare.InPort( 'sigma' , 'long' )
85 Compare.OutPort( 'Result' , 'string' )
86 Compare.SetName( 'Compare' )
87 Compare.SetAuthor( '' )
88 Compare.SetComment( 'Compute Node' )
89 Compare.Coords( 419 , 184 )
92 Addf = Add.Port( 'f' )
93 CompareAdd = GraphCpuUsed.Link( Addf , Compare.Port( 'Add' ) )
94 CompareAdd.AddCoord( 1 , 411 , 265 )
95 CompareAdd.AddCoord( 2 , 411 , 169 )
96 CompareAdd.AddCoord( 3 , 617 , 169 )
97 CompareAdd.AddCoord( 4 , 618 , 8 )
98 CompareAdd.AddCoord( 5 , 401 , 8 )
99 CompareAdd.AddCoord( 6 , 400 , 80 )
101 Subf = Sub.Port( 'f' )
102 Addb = GraphCpuUsed.Link( Subf , Add.Port( 'b' ) )
103 Addb.AddCoord( 1 , 189 , 108 )
104 Addb.AddCoord( 2 , 191 , 220 )
106 sigman = GraphCpuUsed.Link( Subf , sigma.Port( 'n' ) )
107 sigman.AddCoord( 1 , 206 , 254 )
108 sigman.AddCoord( 2 , 206 , 220 )
110 Sigman = GraphCpuUsed.Link( Subf , Sigma.Port( 'n' ) )
111 Sigman.AddCoord( 1 , 389 , 101 )
112 Sigman.AddCoord( 2 , 390 , 160 )
113 Sigman.AddCoord( 3 , 190 , 161 )
114 Sigman.AddCoord( 4 , 190 , 220 )
116 sigmaf = sigma.Port( 'f' )
117 Comparesigma = GraphCpuUsed.Link( sigmaf , Compare.Port( 'sigma' ) )
118 Comparesigma.AddCoord( 1 , 386 , 323 )
119 Comparesigma.AddCoord( 2 , 385 , 253 )
121 Sigmaf = Sigma.Port( 'f' )
122 CompareSigma = GraphCpuUsed.Link( Sigmaf , Compare.Port( 'Sigma' ) )
123 CompareSigma.AddCoord( 1 , 400 , 295 )
124 CompareSigma.AddCoord( 2 , 400 , 153 )
125 CompareSigma.AddCoord( 3 , 595 , 153 )
126 CompareSigma.AddCoord( 4 , 595 , 102 )
128 # Creation of Input datas
129 Adda = Add.Input( 'a' , 1)
130 Suba = Sub.Input( 'a' , 1000)
131 Subb = Sub.Input( 'b' , 1)
133 # Creation of Output variables
134 CompareResult = Compare.Port( 'Result' )
137 while GraphCpuUsed.IsDone() == 0 :
139 print "sigma",sigma.CpuUsed(),"seconds"
140 print "Sigma",Sigma.CpuUsed(),"seconds"
141 print "Add",Add.CpuUsed(),"seconds"
142 print "Sub",Sub.CpuUsed(),"seconds"
143 print "Compare",Compare.CpuUsed(),"seconds"
145 print GraphCpuUsed.State()
146 GraphCpuUsed.PrintPorts()
147 print "sigma",sigma.CpuUsed(),"seconds"
148 print "Sigma",Sigma.CpuUsed(),"seconds"
149 print "Add",Add.CpuUsed(),"seconds"
150 print "Sub",Sub.CpuUsed(),"seconds"
151 print "Compare",Compare.CpuUsed(),"seconds"