TrainDecouple


Decouples a given number of cars from the incoming train and creates a new train from those cars, which exits the block via the output port outDecoupled. The block can handle the extreme cases when 0 cars are decoupled, in which case the original train just proceeds to the port out. The speed and acceleration properties of the original train are copied to the new train. No rail cars change their position during decoupling.

The operation of decoupling is performed immediately as the train enters the TrainDecouple block and takes zero time, so if you wish to model the time delay associated with decoupling, you should add a Delay object after the TrainDecouple block.

Parameters

Decouple
Defines which part of the train should be decoupled:
First cars – the specified number of cars will be decoupled starting from the first car of the train.
Last cars – the specified number of cars will be decoupled starting from the last car of the train.
Syntax: boolean decoupleFirstCars
Default value: First cars (true)
Number of cars to decouple [dynamic]  
The number of cars to decouple. Should be in the range from 0 to the number of cars in the train inclusive. If 0, the whole train exits via out and nothing exits via outDecoupled. If all cars are decoupled, the whole train exits via outDecoupled and nothing exits via out.
Value type: int
Local variable: T1 train – the train that entered the block
Default value: 1
New train [dynamic]
The type of the train created by TrainDecouple. It should be agent type with the option that it is used in flowcharts as train being selected. 
Add train to
Here you specify where the trains created by this block will be stored: in the default population of root agent, or in some custom population (specified below in the Train population property).
Syntax: boolean addToCustomPopulation
Default value: default population of root agent (false)
Train population [dynamic]
[Visible if Add train to is set to Custom population] The name of the agent population where the trains created by this block will be stored.
Local variable: T1 agent – the train created by the block
Actions
On enter [code]
Code executed when the train enters the object.
Local variable: T1 train – the train that entered the block
On exit [code]
Code executed when the original train without the decoupled cars exits the object via port out.
Local variable: T1 train – the train leaving this object via port out
On exit (decoupled) [code]
Code executed when the new train formed from the decoupled cars exits the object via port outDecoupled.
Local variables: T1 train1 – the train leaving this object via port out
             T2 train2 – the train leaving this object via port outDecoupled
Advanced
Train 1 type
The type of train that entered the block This type should have the option that it is used in flowcharts as train. 
Referred as:  T1
Train 2 type
The type of train leaving this object via port outDecoupled. This type should have the option that it is used in flowcharts as train.
Referred as:  T2

Ports

in

The input port.

out

The output port for the original train.

outDecoupled

The output port for the train created from the decoupled cars