<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
                         "http://docbook.org/xml/4.4/docbookx.dtd">
<chapter>
    <title>Switch Component Usage</title>
    <sect1>
        <title>Synopsis</title>
        <para>The Switch component forwards input values to one or more outputs. Whether or not an input is forwarded to a specific output depends 
        on user-specified conditions.</para>
    </sect1>
    <sect1>
        <title>Rationale</title>
        <para>The Switch component allows to direct the data flow within a workflow. It receives
            input values (so-called data input) and forwards them to at least one output (so-called data output). 
            It depends on user-specified conditions to which output the values are forwarded.
            Each condition may evaluate the data input values as well as so-called condition inputs.
            These inputs can be defined but will not be forwarded.
            </para>
    </sect1>
    <sect1>
        <title>Usage</title>
        <para>On the 'Inputs/Outputs' tab the user can define the data inputs to be forwarded. 
        	The default data type of a data input is float. Change the data type to the
            one you require to forward. For each data input several data outputs will be generated automatically. 
            The quantity depends on the number of conditions which can be defined on the 'Condition' tab.
            For one condition, two outputs are created. One output is used to forward the input value in case the 
            condition is true, the other in case the condition is false. For more than one condition there will 
            be one output for each condition plus one output in case no condition evaluates to true. If several 
            conditions evaluate to true, the default behavior is that all input values are written to all 
            related outputs. Optionally the user can decide to write the values only to one related output.</para>
        <para>The naming scheme for the automatically created data outputs is as follows: 
            <code>&lt;data input name>_condition &lt;condition_number></code> and <code>&lt;data_input_name>_no match</code>.
            In addition to the data input, you can create condition inputs. 
            They can only be used within the condition and will therefore not be forwarded.
            The permissible data types are integer, float or boolean.
            </para>
        <para><inlinegraphic fileref="../../images/image001.png"/></para>
        <para>Define your conditions on the 'Condition' tab. A condition may contain data inputs, condition inputs,
            numbers, relational operators and parentheses. You can insert inputs and
            valid operators by hand or you can select them from the drop down list on the right-hand side.
            Inputs can only be used within conditions, if their data type is either
            integer, float or boolean. Only inputs of permissible data types are shown in the drop down list.
            You can add or remove conditions using the plus and minus buttons on the left-hand side.</para>
        <para>You can control to which output the values will be written in case several conditions 
            hold true via the option 'Write values only for the first applicable condition'. If this option is set,
            the data inputs will be forwarded only to the outputs related to the first applicable condition. Otherwise 
            the values will be written to all outputs related to conditions that evaluate to true. You can adjust the order 
            of the conditions via the arrow buttons on the left-hand side.    
             </para>
        <para><inlinegraphic fileref="../../images/image002.png"/></para>
        <para>There are three options available that define the behavior of the Switch component within loops.
        In the 'Loop Control' tab you can choose between:
        <itemizedlist>
                    <listitem>
                        <para>Never close outputs: Use this option if the switch component 
                        is used outside of a loop or if it is not supposed to control the loop.</para>
                    </listitem>
                    <listitem>
                        <para>Close outputs on condition number: Select a condition number from the provided drop down menu.
                        Use this option if the switch component is supposed to control a loop. All inputs of successive components in the workflow
                        which are connected to any output ending with <code>_condition &lt;condition number></code> will be closed. 
                        Note that a component is finished if all of its inputs are closed.</para>
                    </listitem>
                    <listitem>
                        <para>Close outputs if there is no match: Use this option if the switch component is
                        supposed to control a loop. All inputs of successive components in the workflow which are connected to the outputs
                        ending with <code>_no match</code> will be closed. Note that a component is finished if all of its
                        inputs are closed.</para>
                    </listitem>
                </itemizedlist>
        </para>
    </sect1>
</chapter>
