CS452 - Real-Time Programming - Spring 2011
Lecture 24 - Reservations
Pubilic Service Announcement
- Project proposals.
Sensor Attribution
For each train there is a set of predictions
- The primary prediction: if the world is perfect train n will trigger
sensor X between t1 & t2.
- One or more secondary predictions, having one of the two following forms
- If the sensor X fails train n will to trigger sensor Y between t3
& t4
- If switch A is set `incorrectly' train n will to trigger sensor Z
between t5 & t6
- Attribute a sensor hit to train n if it fulfils one of train n's
predictions.
- What if two trains are making the same prediction?
- They are too close together.
- Preventing trains from getting too close together requires
reservations.
This works fine once you have trains moving. How do you get them
moving?
Starting the next train
- Start it slowly, you don't know where it is.
- When it hits a sensor immediately get it a reservation until the next
block ended by a sensor, plus one sensor.
- Conclude that you know where the train is when it hits the predicted
sensor.
Reservations
Somebody has been doing something right for the last century. The answer
is reservations.
Two Level Train Control
The two levels are completely independent of one another.
- On heavily used sections of track the lower level is done completely by
hardware with no possibility (almost) of human intervention.
- The dispatcher, using human judgement, can talk a train through a red
light
Upper Level System
- Train asks despatcher for a route
- Despatcher provides a route that he/she thinks to be conflict free
- Train follows the route, reporting back to the despatcher as landmarks
(sensors) are passed.
- The despatcher gets two reports
- One from the hardware
- One from the engineer
- It is up to the despatcher to make certain that they do not
conflict
Lower Level System (LLS)
The LLS is (mostly) encoded in the coloured lights you see along the
track
- Everything is rigidly enforced by hardware
- The human enters the loop only in that the lights tell the engineer
what he/she is allowed to do
- The engineer loses his licence, FOREVER, if he/she ever goes
through a red light.
- If the system ever gets something it doesn't understand, it enters a
failsafe mode
Here's how the LLS works.
For every section of track the LLS receives one bit of data
- occupied/unoccupied
- produced by the wheels shorting the tracks
And for every turn-out the LLS receives one bit
- straight/curved
- produced by the switch points shorting one track or another
Consider one light facing a specific direction.
- It is normally red.
- The LLS looks one light (block) ahead.
- If, beyond that light, the distance it would take two trains to stop
from the track speed plus one block, has no occupied section it allows
the dispatcher to turn the light green, which means continue at track
speed..
- Otherwise, if there's no occupied block in the distance it would take
to stop two trains at reduced speed, it allows the dispatcher to turn the
light yellow, which means don't go past the next light faster than
reduced speed..
- Otherwise the light is can be turned only blinking red, which means
proceed at a speed from which you can stop before the next light.
You can't implement a two level system.
Why?
The functionality of the LLS must be part of your reservation system. That
is,
- Giving or accepting a reservation must be conditioned on a set of
factors that include those provided by the LLS.
A Typical Reservation System
Hard Conditions
- **Every train must have a reservation for the block it occupies.
- **Every train must travel at a low enough velocity that it can stop
before the end of the blocks it has reserved.
- **Every train should reserve enough to handle single sensor or
(exclusive) single switch errors.
- Every train must release blocks it no longer occupies and will not
occupy in the immediate future
(** failsafe conditions)
Who enforces these conditions?
There is a situation in which these conditions cannot be enforced?
Here's how it works
- Train gets a route from the route finder, and looks ahead along the
route.
- Train has a desired speed (n) and a current velocity (v0)
- Train asks reservation system for several blocks of track
- Blocks usually end at switches and/or sensors
- If you are ending blocks at switches you must know well enough how
enough where the train is to be confident it is completely clear of
the switch.
- Reservation system grants the blocks if they are available
- Grants include the condition that the train must travel so that it
can come to a complete stop without leaving any reserved block.
- In practice this means:
- If all is clear, the train will travel at the same speed until
it makes a new request before the beginning of the next
block.
- At that point it will make a new request, and if that request
is not granted, then it must be able to stop without passing
beyond already reserved track
- In practice you would grant reservations as follows:
- Train is about to enter block n, and is holding reservations to
block n+x, where
- x is defined so that if the train goes to speed zero now it
will stop before the end of block n+x
- First, suppose that the train will continue travelling at the
same speed, s.
- Then it will be travelling at the same speed when it enters
block n+1
- If it goes to train zero at the beginning of block n+1
where will it stop.
- Say, before the end of block n+y, which you calculate using
your calibration.
- Necessarily, y >= x.
- Try to reserve to n+y: if sucessful keep travelling without
reducing speed, i.e. at speed s..
- If unsuccessful reserve as much as you can: say to the end of
block y'
- Calculate, using your calibration, the speed that allows you to
stop by the end of block n+y' if you set the speed to zero at the
beginning of block n+1.
- Check using your calibration that you can reduce to the
steady-state velocity of speed r by the beginning of block n+1.
- You necessarily can by setting the speed to zero.
- Set your speed to the highest speed that allows you to get to
the velocity of speed r by the end of block n+1.
An Interesting Tit-bit That Doesn't Concern You
Real trains are long and sometimes occupy several blocks at once. How does
the engineer know that the end of a train is clear of a switch?
- When an engineer takes over a train he/she is given printed orders that
include the length of the train.
- There is a resetable counter in the locomotive that count the
revolutions of the locomotives wheels
- When the locomotive passes a switch the engineer resets the
counter.
Something Essential that You Must Do
Design your reservation system before coding it.
Before coding your reservation system work it out on paper and make sure
that it works for all the generic cases you can think of
- One train following another
- Two trains on a collision course
- There are one or more switches in the path
Return to: