From c34794e8a1a28826a7e8443b46fa76e0de238978 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Sat, 21 Jul 2018 16:31:00 +0200 Subject: Implement routesetting Missing things: signal aspect updating, waiting routes handling, management /info tool --- advtrains_interlocking/database.lua | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'advtrains_interlocking/database.lua') diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua index 6d86e39..c19f516 100644 --- a/advtrains_interlocking/database.lua +++ b/advtrains_interlocking/database.lua @@ -64,6 +64,7 @@ Whenever train leaves a TC -> Clearing any routes set from this TC outward recursively - see "Reversing problem" Whenever train enters a TC -> Clear route status from the just entered TC +Note that this prohibits by design that the train clears the route ahead of it. == Reversing Problem == Encountered at the Royston simulation in SimSig. It is solved there by imposing a time limit on the set route. Call-on routes can somehow be set anyway. Imagine this setup: (T=Train, R=Route, >=in_dir TCB) @@ -108,10 +109,18 @@ function ildb.load(data) if data.signalass then signal_assignments = data.signalass end + if data.rs_locks then + advtrains.interlocking.route.rte_locks = data.rs_locks + end end function ildb.save() - return {tcbs = track_circuit_breaks, ts=track_sections, signalass = signal_assignments} + return { + tcbs = track_circuit_breaks, + ts=track_sections, + signalass = signal_assignments, + rs_locks = advtrains.interlocking.route.rte_locks, + } end -- @@ -144,9 +153,21 @@ Track section name = "Some human-readable name" tc_breaks = { ,... } -- Bounding TC's (signal specifiers) -- Can be direct ends (auto-detected), conflicting routes or TCBs that are too far away from each other - route = {origin = , from_tcb = } + route = { + origin = , -- route origin + entry = , -- supposed train entry point + rsn = , + first = + } + route_post = { + locks = {[n] = } + next = + } -- Set whenever a route has been set through this TC. It saves the origin tcb id and side - -- (=the origin signal). index is the TCB of the route origin + -- (=the origin signal). rsn is some description to be shown to the user + -- first says whether to clear the routesetting status from the origin signal. + -- locks contains the positions where locks are held by this ts. + -- 'route' is cleared when train enters the section, while 'route_post' cleared when train leaves section. trains = {, ...} -- Set whenever a train (or more) reside in this TC } @@ -379,10 +400,11 @@ function ildb.remove_from_interlocking(sigd) end function ildb.remove_tcb(pos) + local pts = advtrains.roundfloorpts(pos) + if not track_circuit_breaks[pts] then return end for connid=1,2 do ildb.remove_from_interlocking({p=pos, s=connid}) end - local pts = advtrains.roundfloorpts(pos) track_circuit_breaks[pts] = nil end -- cgit v1.2.3