User Tools

Site Tools


usage:atlatc:examples:level_crossing

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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(tdo +
-  occs_present true +
-  break +
-end +
- +
--- Every occupation entry is a table of train IDs occupying it. +
-if not occs_present then+
   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.
-  local train_on_crossing = false +  if next(acwd_occupation[crossing]) == nil then
-  for approach, train_id in pairs(acwd_occupation[crossing]) do +
-      train_on_crossing true +
-      break +
-  end +
-   +
-  if not train_on_crossing then+
     for wd=1,n do     for wd=1,n do
       setstate(crossing .. tostring(wd), "off")       setstate(crossing .. tostring(wd), "off")
Line 170: Line 158:
  
 </code> </code>
 +
 +===== 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("OCA1SM")
 +</code>
 +
 +More information:
 +
 +[[https://www.networkrail.co.uk/wp-content/uploads/2020/03/Enhancing-Level-Crossing-Safety-2019-2029.pdf|Network Rail PDF]]
 +
 +[[https://www.networkrail.co.uk/communities/living-by-the-railway/level-crossing-closures/|Network Rail Post]] (It basically says trains are going faster and there is more risk so they should close more rail crossings)
usage/atlatc/examples/level_crossing.1656904475.txt.gz · Last modified: 2022-07-04 05:14 by blockhead