]> SALOME platform Git repositories - modules/superv.git/blob - examples/GraphLoopSwitch.py
Salome HOME
Error messages
[modules/superv.git] / examples / GraphLoopSwitch.py
1
2 # Generated python file of Graph GraphLoopSwitch_1
3
4 from SuperV import *
5
6 # Graph creation of GraphLoopSwitch_1
7 def DefGraphLoopSwitch_1() :
8     GraphLoopSwitch_1 = Graph( 'GraphLoopSwitch_1' )
9     GraphLoopSwitch_1.SetName( 'GraphLoopSwitch_1' )
10     GraphLoopSwitch_1.SetAuthor( '' )
11     GraphLoopSwitch_1.SetComment( '' )
12     GraphLoopSwitch_1.Coords( 0 , 0 )
13     
14     # Creation of Factory Nodes
15     
16     # Creation of InLine Nodes
17     PyIsOdd = []
18     PyIsOdd.append( 'from time import *    ' )
19     PyIsOdd.append( 'def IsOdd(a,Even) :        ' )
20     PyIsOdd.append( '    print a,"IsOdd (GraphLoopSwitch1)"       ' )
21     PyIsOdd.append( '    sleep( 1 )    ' )
22     PyIsOdd.append( '    return a      ' )
23     IsOdd = GraphLoopSwitch_1.INode( 'IsOdd' , PyIsOdd )
24     IsOdd.SetName( 'IsOdd' )
25     IsOdd.SetAuthor( '' )
26     IsOdd.SetComment( 'Python function' )
27     IsOdd.Coords( 397 , 1 )
28     IIsOdda = IsOdd.InPort( 'a' , 'long' )
29     IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' )
30     IIsOddGate = IsOdd.GetInPort( 'Gate' )
31     OIsOdda = IsOdd.OutPort( 'a' , 'long' )
32     OIsOddGate = IsOdd.GetOutPort( 'Gate' )
33     
34     # Creation of Loop Nodes
35     PyInitLoop = []
36     PyInitLoop.append( 'def InitLoop(Index,Min,Max) : ' )
37     PyInitLoop.append( '        Index = Min ' )
38     PyInitLoop.append( '        return Index,Min,Max ' )
39     PyInitLoop.append( ' ' )
40     PyMoreInitLoop = []
41     PyMoreInitLoop.append( ' ' )
42     PyNextInitLoop = []
43     PyNextInitLoop.append( ' ' )
44     InitLoop,EndOfInitLoop = GraphLoopSwitch_1.LNode( 'InitLoop' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop )
45     EndOfInitLoop.SetName( 'EndOfInitLoop' )
46     EndOfInitLoop.SetAuthor( '' )
47     EndOfInitLoop.SetComment( 'Compute Node' )
48     EndOfInitLoop.Coords( 767 , 102 )
49     PyEndOfInitLoop = []
50     PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' )
51     PyEndOfInitLoop.append( '   Index = Index + 1     ' )
52     PyEndOfInitLoop.append( '   if Index <= Max :   ' )
53     PyEndOfInitLoop.append( '           DoLoop = 1     ' )
54     PyEndOfInitLoop.append( '   else :     ' )
55     PyEndOfInitLoop.append( '           DoLoop = 0     ' )
56     PyEndOfInitLoop.append( '   return DoLoop,Index,Min,Max     ' )
57     EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop )
58     IInitLoopDoLoop = InitLoop.GetInPort( 'DoLoop' )
59     IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' )
60     IInitLoopMin = InitLoop.InPort( 'Min' , 'long' )
61     IInitLoopMax = InitLoop.InPort( 'Max' , 'long' )
62     IInitLoopGate = InitLoop.GetInPort( 'Gate' )
63     OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' )
64     OInitLoopIndex = InitLoop.GetOutPort( 'Index' )
65     OInitLoopMin = InitLoop.GetOutPort( 'Min' )
66     OInitLoopMax = InitLoop.GetOutPort( 'Max' )
67     IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' )
68     IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' )
69     IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' )
70     IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' )
71     IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' )
72     OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' )
73     OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
74     OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
75     OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
76     InitLoop.SetName( 'InitLoop' )
77     InitLoop.SetAuthor( '' )
78     InitLoop.SetComment( 'Compute Node' )
79     InitLoop.Coords( 10 , 108 )
80     
81     # Creation of Switch Nodes
82     PySwitch = []
83     PySwitch.append( 'from time import *  ' )
84     PySwitch.append( 'def Switch(a) :    ' )
85     PySwitch.append( '    if ( a & 1 ) == 0 :  ' )
86     PySwitch.append( '        sleep(1)  ' )
87     PySwitch.append( '    return a & 1,1-(a&1),a    ' )
88     Switch,EndSwitch = GraphLoopSwitch_1.SNode( 'Switch' , PySwitch )
89     EndSwitch.SetName( 'EndSwitch' )
90     EndSwitch.SetAuthor( '' )
91     EndSwitch.SetComment( 'Compute Node' )
92     EndSwitch.Coords( 587 , 103 )
93     PyEndSwitch = []
94     PyEndSwitch.append( 'def EndSwitch(a) :    ' )
95     PyEndSwitch.append( '    if ( a & 1 ) == 0 :  ' )
96     PyEndSwitch.append( '        sleep(1)  ' )
97     PyEndSwitch.append( '    return a    ' )
98     EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch )
99     IEndSwitcha = EndSwitch.InPort( 'a' , 'long' )
100     IEndSwitchDefault = EndSwitch.GetInPort( 'Default' )
101     OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' )
102     OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' )
103     Switch.SetName( 'Switch' )
104     Switch.SetAuthor( '' )
105     Switch.SetComment( 'Compute Node' )
106     Switch.Coords( 194 , 109 )
107     ISwitcha = Switch.InPort( 'a' , 'long' )
108     ISwitchGate = Switch.GetInPort( 'Gate' )
109     OSwitchOdd = Switch.OutPort( 'Odd' , 'long' )
110     OSwitchEven = Switch.OutPort( 'Even' , 'int' )
111     OSwitcha = Switch.OutPort( 'a' , 'int' )
112     OSwitchDefault = Switch.GetOutPort( 'Default' )
113     
114     # Creation of Links
115     LIsOddaEndSwitcha = GraphLoopSwitch_1.Link( OIsOdda , IEndSwitcha )
116     LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 )
117     LIsOddaEndSwitcha.AddCoord( 2 , 575 , 81 )
118     
119     LInitLoopIndexSwitcha = GraphLoopSwitch_1.Link( OInitLoopIndex , ISwitcha )
120     
121     LInitLoopMinEndOfInitLoopMin = GraphLoopSwitch_1.Link( OInitLoopMin , IEndOfInitLoopMin )
122     
123     LInitLoopMaxEndOfInitLoopMax = GraphLoopSwitch_1.Link( OInitLoopMax , IEndOfInitLoopMax )
124     
125     LSwitchOddIsOddGate = GraphLoopSwitch_1.Link( OSwitchOdd , IIsOddGate )
126     
127     LSwitchEvenEndSwitchDefault = GraphLoopSwitch_1.Link( OSwitchEven , IEndSwitchDefault )
128     
129     LSwitchEvenIsOddEven = GraphLoopSwitch_1.Link( OSwitchEven , IIsOddEven )
130     LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 111 )
131     LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 172 )
132     
133     LSwitchaIsOdda = GraphLoopSwitch_1.Link( OSwitcha , IIsOdda )
134     LSwitchaIsOdda.AddCoord( 1 , 362 , 82 )
135     LSwitchaIsOdda.AddCoord( 2 , 360 , 201 )
136     
137     LEndSwitchaEndOfInitLoopIndex = GraphLoopSwitch_1.Link( OEndSwitcha , IEndOfInitLoopIndex )
138     
139     # Input datas
140     IInitLoopIndex.Input( 0 )
141     IInitLoopMin.Input( 5 )
142     IInitLoopMax.Input( 100 )
143     
144     # Output Ports of the graph
145     #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' )
146     #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' )
147     #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' )
148     return GraphLoopSwitch_1
149
150
151 GraphLoopSwitch_1 = DefGraphLoopSwitch_1()