TrainSource

TrainSource
is the block that starts any railway process flow.
It generates trains, places them on the tracks in the rail yard and injects the train into the train process flowchart.
You can set the block not to place created trains on a track of the rail yard (this behavior is controlled with the
After creation
parameter). It is commonly used when you need to pass the train agent
to the regular process flowchart where it can go through delays,
queues, decisions, etc. and place it on a track of the rail yard later
on (using
TrainEnter
block).
Train "arrival times", i.e. the times when new trains appear in the model can be set up similarly to the
Source
block in the
Process Modeling Library
(an in fact,
Source
is used inside the
TrainSource). Arrivals can defined by interarrival times or by arrival schedule. In addition, there is a "manual mode" when
TrainSource
would create a train only when its
inject()
function is called. Just like in
Source, you can limit the number of arrivals.
A new train should contain at least one rail car. You can tell
TrainSource
to use your own rail car type. The same applies for the train.
You
can assign custom 2D or 3D animation shapes to the cars and perform any
additional setup for each car, for example, set up a custom length, in
the Car setup
field. Please note that the size of rail car custom animation will not
be automatically adjusted to the length of the rail car, so you need to
choose the proper scale of the animation shape so that there are no
spaces between cars in the train and cars are not drawn one above the
other.
A new
train is placed on a track and can occupy several tracks. You need to
specify the offset of the first car on the track and orientation of the
train relative to the track. If the train doesn't fit on a single
track, it will occupy the next track according to the nearest switch.
A
train has its first car (the one that has been created first) and the
last car. In the train API "front" always means the first car.
The train cruise speed and acceleration/deceleration, are also defined in the
TrainSource
block but can be modified later via the train API. The speed of the
train is at this time set to its cruise speed, so that, if needed, the
train can start immediately at the cruise speed.
Parameters
- [Note that in the descriptions below
RC
refers to the type specified by the user in the
New rail car
field. In the similar way,
T
refers to the type specified by the user in the
New train
field.]
- Arrivals defined by
- Specifies the mode of train generation:
Interarrival time
- the time between two subsequent trains is defined by the specified expression.
Arrival
table in Database
- trains are generated according to the records in the specified database table. You specify the table below in the
Database table
parameter, then select the table column containing the arrival moments in the
Arrival date
drop-down list. The block will generate one train per each data record in the specified table.
Arrival schedule
– trains are generated at exact times defined in the arrival schedule.
Manual (call inject() method)
- trains are not generated automatically and are only generated on calls of
inject()
method.
Get value:
arrivalType
Set new value dynamically:
set_arrivalType(
new value
)
Valid values:
Interarrival time
- trainSource.INTERARRIVAL_TIME
Arrival
table in Database
- trainSource.DATABASE_ARRIVAL_TABLE
Arrival schedule
- trainSource.ARRIVAL_SCHEDULE
Manual (call inject() method) - trainSource.MANUAL
- Interarrival time
[dynamic]
- [Visible if
Arrivals defined by
is set to
Interarrival time] Expression used to evaluate the time interval between the two subsequent trains.
Value type:
double
Default value:
10
minutes
- First arrival occurs
- [Visible if
Arrivals defined by
Interarrival time] Specifies the time of the first train arrival to block
TrainSource.
After timeout
- the first arrival occurs after the time specified in
Interarrival time
parameter has run out.
At model start
- the first arrival occurs when the model is run.
At the specified time
- the first arrival occurs at the moment of time specified in the
First arrival time
parameter.
Syntax:
com.anylogic.libraries.rail.RailConstants.FirstArrivalMode firstArrivalMode
Valid values: trainSource.AFTER_TIMEOUT; trainSource.AT_START; trainSource.AT_TIME
- First arrival time
- [Visible if
First arrival occurs
At the specified time] The exact time when the
TrainSource
block generates the first train. This time cannot be less that the
model run time or the time of creation and initialization of this TrainSource
block.
Syntax: double firstArrivalTime
- Arrival schedule
- [Visible if
Arrivals defined by
is set to
Arrival schedule] The name of the
Schedule
object with integer value type containing times of train arrivals.
Typically, the value column would contain "1" as one train is generated
at a time.
Syntax:
Schedule<Integer>
arrivalSchedule
- Limited number of arrivals
- If the option is selected (true), the number of arrivals will be limited to
Maximum number of arrivals.
Syntax:
boolean limitArrivals
Default value:
false
- Maximum number of arrivals
- [Visible when the
Limited number of arrivals
is selected] The maximum number of arrivals to be generated by this block.
Syntax:
int maxArrivals
Default value:
1000
- Database table
- [Visible if
Arrivals defined by:
Arrival
table in Database] Choose here the database table containing the data on agent arrivals.
- Arrival date
- [Visible if
Arrivals defined by:
Arrival
table in Database] Choose here the column of the
Database table
that contains the agent arrival timestamps.
- # of cars (including loco)
[dynamic]
- The number of cars in the train. Must be 1 or more.
Value type:
int
Default value:
11
- After creation
- Defines what to be done with the created train. There are two options available:
Put the train in a rail yard
- The train will be put into the specified rail yard (in this case you
specify the rail yard, the track, offset, and orientation on the track
using the parameters given below).
Leave as a logical agent (will use TrainEnter later on)
- The train will not be placed on the track of the rail yard by this
block. This option is commonly used when you need to pass the train
agent to the regular process flowchart where it can go through delays,
queues, decisions, etc. and place it on a track of the rail yard later
on (using
TrainEnter
block).
Syntax:
boolean putInRailYard
Default value:
Put the train in a rail yard
(true)
- Entry point defined as
- [Visible if
After creation
is set to
Put the train in a rail yard] Here you can choose how you will define the position on track where new trains will be placed.
There are two alternative options:
Position on track
- Define the point graphically with specific space markup element
Position on track.
Offset on the track
- Define the point as the distance from the start or end point of the
track to the front side of the first car of the train, in the units
specified on the right. You specify the offset in the parameter Offset of 1st car, see below.
Name:
locationType
- Position on track
[dynamic]
- [Visible if
After creation
is set to
Put the train in a rail yard
and
Entry point
defined as
Position on track] Here you should choose the
Position on track
element defining the point of the track where new trains will be placed.
Value type:
PositionOnTrack
Local variable:
T train - the train
- Railway track
[dynamic]
- [Visible if
After creation
is set to
Put the train in a rail yard
and
Entry point defined as
is set to
Offset on the track] The
railway track
where the newly created train will be placed (all cars should be fully located on a single track).
Value type:
RailwayTrack
Local variable:
T train - the train
- Offset from
[dynamic]
- [Visible if
Entry point defined as
Offset on the track] Choose here where to count the offset from:
End of the track
or
Beginning of the track.
Value type:
boolean
Default value:
false
(from the end of the track)
Local variable:
T train - the train
- Offset of 1st car
[dynamic]
- [Visible if
After creation
is set to
Put the train in a rail yard
and
Entry point defined as
Offset on the track] The distance from the start or end point of the track to the front side of the first car of the train.
Type:
double
Default value:
tracklength - 10
Local variables:
double tracklength - the length of the track
T train - the train
- Orientation on track
[dynamic]
- [Visible if
After creation
is set to
Put the train in a rail yard] Defines the orientation of the train relative to the track:
Forward (first car is closer to the end of the track)
– the train orientation is the same as the track
Backward (first car is closer to the beginning)
– opposite orientation
Syntax:
boolean orientation
Default value:
Forward (first car is closer to the end of the track) -
true
Local variable:
T train - the train
-
Train and cars
- New train
[dynamic]
- The train type created by this
TrainSource. (This type should have the option that it is used in flowcharts as train.)
Value type:
Agent
- Initial speed
[dynamic]
- Initial
speed of the train. This speed must be >= 0. If the initial speed is
less than the cruise speed, the train will start accelerating to its
cruise speed from the moment it appears on the track.
Value type:
double
Default value:
20
meters per second
Local variable:
T train - the train
- Cruise speed
[dynamic]
- The
cruise speed of the train. This speed must be > 0. It will be used
as default but you can change it later on via the train API or in the TrainMoveTo
block.
Value type:
double
Default value:
20
meters per second
Local variable:
T train - the train
- Acceleration
[dynamic]
- The
acceleration of the train. This value must be > 0. When you request
the train to accelerate to a desired speed, the speed will be growing
by acceleration value each second. The acceleration can be changed
later on via the train API.
Value type:
double
Default value:
1 meters/seconds2
Local variable:
T train - the train
- Deceleration
[dynamic]
- The
deceleration of the train. This value must be > 0. When you request
the train to decelerate to a desired speed, or to stop, the speed will
be reducing by deceleration value each time unit. The deceleration can
be changed later on via the train API.
Value type:
double
Default value:
2 meters/seconds2
Local variable:
T train - the train
- Add trains 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 addTrainToCustomPopulation
Default value:
Default population of root agent
(false)
- Train population
[dynamic]
- [Visible if
Add trains to
is set to
Custom population] The name of the agent population where the rail cars created by this block will be stored.
Value type:
AgentList