This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
usage:atlatc:examples:level_crossing [2022-07-04 05:14] blockhead list alternatives; add an untested implementation based on lifo's |
usage:atlatc:examples:level_crossing [2022-07-04 13:31] (current) 56independent [Implementation 3] Add resources |
||
---|---|---|---|
Line 95: | Line 95: | ||
-- locals for speed | -- locals for speed | ||
local acwd_occupation = S.acwd_occupation or {} --safe to re-run init code | local acwd_occupation = S.acwd_occupation or {} --safe to re-run init code | ||
- | local occs_present = false | + | if next(acwd_occupation) == nil then |
- | for k,v in pairs(t) do | + | |
- | occs_present | + | |
- | break | + | |
- | end | + | |
- | + | ||
- | -- Every occupation entry is a table of train IDs occupying it. | + | |
- | if not occs_present | + | |
for location, numcrossings in pairs(acwd_occupation) do | for location, numcrossings in pairs(acwd_occupation) do | ||
+ | -- Every occupation entry is a table of train IDs occupying it. | ||
acwd_occupation[location] = {} | acwd_occupation[location] = {} | ||
end | end | ||
Line 156: | Line 150: | ||
-- There must be no trains on any approach to the crossing to | -- There must be no trains on any approach to the crossing to | ||
-- be able to clear it and disable the warning devices. | -- be able to clear it and disable the warning devices. | ||
- | | + | |
- | for approach, train_id in pairs(acwd_occupation[crossing]) | + | |
- | train_on_crossing | + | |
- | break | + | |
- | end | + | |
- | + | ||
- | if not train_on_crossing | + | |
for wd=1,n do | for wd=1,n do | ||
setstate(crossing .. tostring(wd), | setstate(crossing .. tostring(wd), | ||
Line 170: | Line 158: | ||
</ | </ | ||
+ | |||
+ | ===== Implementation 3 ===== | ||
+ | <code lua> | ||
+ | -- The safest level crossing is no crossing. The path passes above or below the track and does not force people to cross the track. This track just keeps a train at mainline programming. | ||
+ | |||
+ | atc_send(" | ||
+ | </ | ||
+ | |||
+ | More information: | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// |