/assets/interlocking.html.LyXconv/

an class="hl com"> u = <unit identifier> } The "unit identifier" is there to prevent schedule overflows. It can be, for example, the position hash of a node or a train ID. If the number of schedules for a unit exceeds UNITS_THRESH, further schedules are blocked. ]]-- local queue = {} local units_cnt = {} function sched.load(data) if data then for i,elem in ipairs(data) do table.insert(queue, elem) units_cnt[elem.u] = (units_cnt[elem.u] or 0) + 1 end atlog("[lines][scheduler] Loaded the schedule queue,",#data,"items.") end end function sched.save() return queue end function sched.run() local ctime = ln.rwt.get_time() local cnt = 0 local ucn, elem while cnt <= MAX_PER_ITER do elem = queue[1] if elem and elem.t <= ctime then table.remove(queue, 1) if callbacks[elem.e] then -- run it callbacks[elem.e](elem.d) else atwarn("[lines][scheduler] No callback to handle schedule",elem) end cnt=cnt+1 ucn = units_cnt[elem.u] if ucn and ucn>0 then units_cnt[elem.u] = ucn - 1 end else break end end end