Switch nodes

Switch node is a kind of Control node. In fact two nodes present Switch: start Switch and end Switch. Nodes of such type are always InLine nodes. You have to supply this type of node by service, which will perform switching. That's why nodes of such type can have at least two or more switch ports (Boolean), but only one switch port can have "True" value at a definite moment of graph execution. With that kind of node you can define all kinds of tests or switches :

“if( condition ) ; else if( condition ) … ; else” or

“switch( variable ) ; case value …; default”.

Etc…

 

 

Titles of the nodes. By default the name of the service is used. You can change only the name of the Start Switch node - the name of the End Switch node will be automatically created as follows: EndOf + "Name of the Start Switch node" .

Status of execution shows state of the loop. It can be: Not Started, Running, Finished.

InGate/OutGate - control ports of the loop execution.

SwitchPort – ports for control management of the Switch. The values in this ports are of boolean type and can be 0 or 1. They must be connected to InGate ports of the correspondent computation nodes.

Input/Output ports –  Input port of the Start Switch node will get the initial value, which can be processed by underlying Python function and will be transferred inside of the switch. The last computation node of the switch will put this value to the input port of the End Switch node.

 

The associated Python function will have all input ports of the Switch node as input arguments. And that function must return a value for all output ports. A simple example of this Python function:

 

def Switch(x):    

i1=0    

i2=0    

i3=0    

if x>13:    

i1=1    

elif x==13:    

i2=1    

else:    

i3=1    

return i1,i2,i3

   

In this example i1, i2, i3 parameters of the function correspond to Switch ports of the node. So, depending on the result of execution of the initial condition (in our case it's a comparison of the input parameter with an integer 13), one of the switch ports will get the value 1. And this port will transmit further dataflow  to the corresponding node.

 

Switch nodes have the following particularities:

 

 

 

Related Topics