Loop node is a kind of Control nodes. In fact two nodes represent Loop: start loop and end loop nodes. Nodes of such type are always InLine nodes. User have to supply this type of node by service, which will check conditions of end of loop.
With that kind of nodes you may define all kinds of loops:
“for( initial condition(s) ; end condition(s) ; end loop code )” or
“while( end condition )”
etc…
Titles of the nodes. By default the name of the service is used. You can change only the name of the Start Loop node - the name of the End Loop node will be automatically created as follows: EndOf + "Name of the Start Loop node" .
Status of execution shows the state of the loop. It can be: Not Started, Running, Finished.
InGate/OutGate - control ports of the loop execution.
Time of execution is a time of node execution in a launched dataflow.
Input/Output ports – are BusPorts, which are processed by Python function. Input ports of the Start Loop node will get the initial values, which can be processed by underlying function and will be transferred inside of the loop. Last calculation node of the loop will put these values to the input port of the End Loop node. If loop continues then this value will be copied to the Input port of the Start Loop node, otherwise into output port of the End Loop node.
Control loop ports – Control ports of the loop nodes manage the functioning of the loop and they are not accessible for the user. InitLoop port launches the loop. DoLoop port of the Start Loop node checks whether the end loop condition set in More function of the Loop node has been achieved or not. The value in this ports is of boolean type. It can be 0 or 1.
To create a Loop node you have to define three python functions which will manage the loop with all input and output arguments (ports) defined in the node :
INIT: An Initialization function which will be executed only when we enter in the loop for the first time.
MORE: A “More” function which is executed at each execution of the LoopNode even for the first time. That function will have to return as first output argument a boolean before output arguments (ports) defined by the user in the node. If that function value is true the body of the loop will automatically be executed. If it is false SUPERVISION component will resume execution after the end of the loop. That first output argument will not be represented as an output port and will not be used in the graph.
NEXT: A “Next” function which is executed each time that SUPERVISION component resume the execution from the end of the loop to the beginning.
Setting of these functions is possible from the standard Add Node dialog box (see also Adding nodes):
Here you can see a simple example of Python functions set in a Loop node:
def Init(Index,Min,Max,Incr) :
if Min <= Max :
Index = Min
else :
Index = Max
return Index,Min,Max,Incr
def More(Index,Min,Max,Incr) :
if Index < Max :
DoLoop = 1
else :
DoLoop = 0
return DoLoop,Index,Min,Max,Incr
def Next(Index,Min,Max,Incr) :
Index = Index + Incr
return Index,Min,Max,Incr
Loop nodes have the following particularities:
You may create only input ports in the Loop node.
The input ports, which have been created in the Start Loop node are automatically duplicated by SUPERVISION component as output ports of this node.
SUPERVISION component automatically adds the same input and output ports in the End Loop node as in the Start Loop node.
If an output port of the Start Loop node has no link and if the corresponding input port of the End Loop node has no link, SUPERVISION component automatically transmits its value to the corresponding End Loop node during execution. You shouldn't define such links.
When SUPERVISION component executes the End Loop node, it automatically transmits the actual values of the output ports of the End Loop node to the input ports of the Start Loop node.
In the body of a loop, an input port of a calculation node may not be linked from an output port of a node which is not in the body of a loop. That output port must be linked to an input port of the Start Loop node. So its value will be available through the corresponding output port of the Start Loop node.