Approach control functions.
Approach control signals are used, specifically in the UK, to keep a signal at 'danger' until the train is within a specific distance ahead of the signal, or has reduced its speed to a specific value. Such control is used for diverging routes, to ensure the speed of the train is reduced sufficiently to safely negotiate the switches onto the diverging route.
For use in OR, two script functions have been defined which can be used to control the signal until the train has reached a specific position or reduced its speed.
These functions are :
- APPROACH_CONTROL_POSITION(position)
- APPROACH_CONTROL_SPEED(position, speed)
These functions are Boolean functions, returned value is 'true' if a train is approaching the signal and is within required distance of the signal and, for APPROACH_CONTROL_SPEED, has reduced its speed below the required values.
Parameters :
position : required distance of train approaching the signal, in
meter.
speed : required speed, in
meter/sec.
Note that the speed is checked only when the train is within the defined distance.
Important note :
Allthough the script uses 'float' to define local variables, these are in fact all
integers.
This is also true for the values used in these functions : if direct values are used, these must be integer values.
The values may be set directly in the signalscript, either as variables or as numbers in the function call.
However, it is also possible to define the required limits in the sigcfg.dat file as part of the signal definition.
The syntax definition for this is :
ApproachControlLimits ( <definitions> )
Allowed definitions :
- Position :
- Positionm : position in meter.
- Positionkm : position in kilometer.
- Positionmiles : position in miles.
- Positionyd : position in yards.
- Speed :
- Speedkph : speed in km / hour.
- Speedmph : speed in miles / hour.
These values are referenced in the script file using the following variable names :
- Approach_Control_Req_Position
- Appraoch_Control_Req_Speed
These variables must not be defined as floats etc., but can be used directly without prior definition.
Note that the values as defined in the sigcfg.dat file will be converted to meter and meter/sec and rounded to the nearest integer value.
Example.
This example is a three-head search light signal, which uses Approach Control if the route is set to the 'lower' head.
Route selection is through 'dummy' DISTANCE type route-selection signals.
Signal defintion :
SignalType ( "SL_J_40_LAC"
SignalFnType ( NORMAL )
SignalLightTex ( "bltex" )
SigFlashDuration ( 0.5 0.5 )
SignalLights ( 8
SignalLight ( 0 "Red Light"
Position ( 0 6.3 0.11 )
Radius ( 0.125 )
)
SignalLight ( 1 "Amber Light"
Position ( 0 6.3 0.11 )
Radius ( 0.125 )
)
SignalLight ( 2 "Green Light"
Position ( 0 6.3 0.11 )
Radius ( 0.125 )
)
SignalLight ( 3 "Red Light"
Position ( 0 4.5 0.11 )
Radius ( 0.125 )
)
SignalLight ( 4 "Amber Light"
Position ( 0 4.5 0.11 )
Radius ( 0.125 )
)
SignalLight ( 5 "Green Light"
Position ( 0 4.5 0.11 )
Radius ( 0.125 )
)
SignalLight ( 6 "Amber Light"
Position ( 0 2.7 0.11 )
Radius ( 0.125 )
)
SignalLight ( 7 "White Light"
Position ( 0 2.7 0.11 )
Radius ( 0.125 )
)
)
SignalDrawStates ( 8
SignalDrawState ( 0
"Red"
DrawLights ( 1
DrawLight ( 0 )
)
)
SignalDrawState ( 1
"TopYellow"
DrawLights ( 1
DrawLight ( 1 )
)
)
SignalDrawState ( 2
"TopGreen"
DrawLights ( 1
DrawLight ( 2 )
)
)
SignalDrawState ( 3
"TopYellowMidGreen"
DrawLights ( 2
DrawLight ( 1 )
DrawLight ( 5 )
)
)
SignalDrawState ( 4
"MidYellow"
DrawLights ( 2
DrawLight ( 0 )
DrawLight ( 4 )
)
)
SignalDrawState ( 5
"MidGreen"
DrawLights ( 2
DrawLight ( 0 )
DrawLight ( 5 )
)
)
SignalDrawState ( 6
"LowYellow"
DrawLights ( 3
DrawLight ( 0 )
DrawLight ( 3 )
DrawLight ( 6 )
)
)
SignalDrawState ( 7
"LowWhite"
DrawLights ( 3
DrawLight ( 0 )
DrawLight ( 3 )
DrawLight ( 7 SignalFlags ( FLASHING ))
)
)
)
SignalAspects ( 8
SignalAspect ( STOP "Red" )
SignalAspect ( STOP_AND_PROCEED "LowWhite" SpeedMPH(25) )
SignalAspect ( RESTRICTING "LowYellow" SpeedMPH(25) )
SignalAspect ( APPROACH_1 "MidYellow" SpeedMPH(40) )
SignalAspect ( APPROACH_2 "TopYellowMidGreen" )
SignalAspect ( APPROACH_3 "TopYellow" )
SignalAspect ( CLEAR_1 "MidGreen" SpeedMPH(40) )
SignalAspect ( CLEAR_2 "TopGreen" )
)
ApproachControlSettings (
PositionM ( 500 )
SpeedMpH ( 10 )
)
SignalNumClearAhead ( 5 )
)
Signal function (reduced to show use of approach control only).
This function uses approach control for the 'lower' route.
///////////////////////////////////////////////////////////////////////////////
SCRIPT SL_J_40_LAC
// Searchlight Top Main Junction
extern float block_state ();
extern float route_set ();
extern float def_draw_state ();
extern float next_sig_lr ();
extern float sig_feature ();
extern float state;
extern float draw_state;
extern float enabled;
//
// Returned states
// drawn :
// SIGASP_STOP
//
// Top Cleared :
// SIGASP_APPROACH_3
// SIGASP_APPROACH_2
// SIGASP_CLEAR_2
//
// Middle Cleared :
// SIGASP_APPROACH_1
// SIGASP_CLEAR_1
//
// Lower Cleared :
// SIGASP_RESTRICTING
// SIGASP_STOP_AND_PROCEED
//
//
// User Flags
//
// USER1 : copy top approach
// USER2 : top approach junction
// USER3 : copy middle approach
// USER4 : no check block for lower
//
float clearstate;
float setstate;
float diststate;
float adiststate;
float nextstate;
float routestate;
float blockstate;
blockstate = 0;
clearstate = 0;
routestate = 0;
setstate = 0;
nextstate = next_sig_lr(SIGFN_NORMAL);
diststate = next_sig_lr(SIGFN_DISTANCE);
adiststate = diststate;
if (diststate ==# SIGASP_CLEAR_1)
{
diststate = SIGASP_CLEAR_2;
}
if (diststate ==# SIGASP_APPROACH_1)
{
diststate = SIGASP_APPROACH_3;
}
// get block state
if (!enabled)
{
clearstate = -1;
}
if (block_state () ==# BLOCK_JN_OBSTRUCTED)
{
clearstate = -1;
}
if (block_state() ==# BLOCK_OCCUPIED)
{
blockstate = -1;
}
// check if distant indicates correct route
if (diststate ==# SIGASP_STOP)
{
clearstate = -1;
}
// top route
state = SIGASP_STOP;
if (blockstate == 0 && clearstate == 0 && diststate ==# SIGASP_CLEAR_2)
{
// aspect selection for top route (not shown)
.......
}
// middle route
if (blockstate == 0 && clearstate == 0 && diststate ==# SIGASP_APPROACH_3)
{
// aspect selection for middle route (not shown)
.......
}
// lower route
if (blockstate == 0 && clearstate == 0 && diststate ==# SIGASP_RESTRICTING)
{
if (Approach_Control_Speed(Approach_Control_Req_Position, Approach_Control_Req_Speed))
{
state = SIGASP_RESTRICTING;
}
}
// Get draw state
draw_state = def_draw_state (state);
Regards,
Rob Roeterdink