Fluid Select Input

Routes the flow from one of the two inputs to the output (the input is set in the parameter Select). 

FluidSelectInput is a zero-capacity block, it does not contain any amount of fluid.

The output batch of the FluidSelectInput block is the same as the one at the selected input. The On new batch … actions can be used to switch the input depending on the incoming batches.

Changing the input dynamically at model runtime

The input selected at design time can be changed at runtime by calling the functions toggle() and select().

For example, the block is named selectInput. To select input 1 at runtime, call: selectInput.select(1)
To select input 2: selectInput.select(2)

Demo model: FluidSelectInput

Parameters

Select
Here you can choose whether the flow from Input 1, or Input 2 goes into the output. When the input 1 is selected, input 2 is blocked, and vice versa. If the value is set to true, the flow goes from the input 1.
Syntax: boolean selectInput1
Limited output rate
If the option is selected (the value is equal to true), you are able to specify a custom upper limit of the output rate.
Syntax: boolean limitRateOut
Change the value at runtime: set_limitRateOut(true or false
Maximum output rate
[Visible and applies only if the Limited output rate option is set] Custom upper limit of the output rate. The default value is 10 cubic meters per second.
Syntax: double maxRateOut
Set new value at runtime: set_maxRateOut(new value)
Animation
Show batches in flowchart
If set, the block icon will display the current batch color.
Syntax: boolean showBatchesInFlowchart
Actions
On new batch at input 1 [code]
Action executed when a new batch appears at the input 1. It will not necessarily start flowing into the block. You can, for example, change the selected input in this action.
Local variable: Object batch - the batch
On new batch at input 2 [code]
Action executed when a new batch appears at the input 2. It will not necessarily start flowing into the block. You can, for example, change the selected input in this action.
Local variable: Object batch - the batch
On rate change [code]
Action executed when any of the flow rates changes. Please note that changing something in the action may result in another immediate rate change and immediately following another call of On rate change, so the user can possibly create a livelock.
Local variables:  double in1rate - the current input rate at port in1
             double in2rate - the current input rate at port in2
                          double outrate - the current output rate

Functions

double amountPassed() - Returns the total amount passed through the output port since the start of the simulation.

double amountPassed(AmountUnits units) - Returns the total amount of fluid (in given units) passed through the out port of the block since the start of the simulation.

void resetStats() - Resets statistics collected for this block, including the statistics collected for its ports.

double currentRate() - Returns the current flow rate of fluid that goes out.

double currentRate(FlowRateUnits units) - Returns the current flow rate (in given units) of fluid at the block output.

toggle() - Selects the input different to the one currently selected.

select(int input) - Selects the specified input (input argument must be 1 or 2).

Ports

in1
The upper input port, Input 1.
in2
The lower input port, Input 2.
out
The output port.