Behavior / SwitchCase
Block Name: SwitchCase
- public class Switch_One_X_Four
- extends TypedAtomicActor
- This block has two input ports, the input port for incoming data tokens and the control port to select the output data path, and 5 output ports, four for the matched output and one for the no_output. This 1 X 4 basic switch routes input tokens to the zero, one, two, or three output ports selected by the value on the control port. If the value on the control port matches the Relative Address range (Relative Address 0 includes 0, 1, 2, 3 and Relative_Address 4 means 4, 5, 6, 7) in the Switch_Address parameter then the token on the input port is placed on the corresponding output. So, a value 1 on the control port with Relative_Address=0 will send the input token on the one_output and control value 6 with Relative_Address=4 will send the input token on two_output. If the value on the control port is outside the range, then the incoming token is placed on the no_output port. If a second inputs arrive before a control port value, the first value is overwritten. The input token can be of any data type (int, long, double, boolean, string, data structure).
- For example, if the control value is 1 and the Relative address is 0-3, then the data is placed on the second output port. If the Relative Address is 4-7 and the control value is 1, then the DS is placed on the no_output port. The no_output can be cascaded with additional Four_X_One blocks and the Relative_address set to the next range. The address range support can extend from 0-31. The no_output port can be connected to the input port of another One_X_Four block. In this way, 8 blocks can be connected in cascade to create a 32 port system.
input
public TypedIOPort input
- Input port for data tokens. This can accept any Data Type.
control
public TypedIOPort control
- Input port for control tokens, which selects the output based on the relative switch address. The type is integer.
zero_output
public TypedIOPort zero_output
- Zero output port, relative to switch address, and selected by the control value. The type is same as input.
one_output
public TypedIOPort one_output
- One output port, relative to switch address, and selected by the control value. The type is same as input.
two_output
public TypedIOPort two_output
- Two output port, relative to switch address, and selected by the control value. The type is same as input.
three_output
public TypedIOPort three_output
- Three output port, relative to switch address, and selected by the control value. The type is same as input.
no_output
public TypedIOPort no_output
- Data is sent to this port when the control port value is out of the switch_address range. The type is same as input.
Switch_Address
public StringAttribute Switch_Address
- The relative address operator. This is a string-valued attribute that defaults to "Relative ADDR = 0".
Created with the Personal Edition of HelpNDoc: Easily create EBooks