diff options
author | orwell96 <orwell@bleipb.de> | 2018-07-21 16:31:00 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-07-21 16:31:00 +0200 |
commit | c34794e8a1a28826a7e8443b46fa76e0de238978 (patch) | |
tree | c4b424764498f14dad06640607e557280f715c7c /advtrains_interlocking/train_related.lua | |
parent | 5fc5eb9c2abd1cc30277cfda953b4696274ecd31 (diff) | |
download | advtrains-c34794e8a1a28826a7e8443b46fa76e0de238978.tar.gz advtrains-c34794e8a1a28826a7e8443b46fa76e0de238978.tar.bz2 advtrains-c34794e8a1a28826a7e8443b46fa76e0de238978.zip |
Implement routesetting
Missing things: signal aspect updating, waiting routes handling, management /info tool
Diffstat (limited to 'advtrains_interlocking/train_related.lua')
-rw-r--r-- | advtrains_interlocking/train_related.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/advtrains_interlocking/train_related.lua b/advtrains_interlocking/train_related.lua index 3d7e280..2dfbd5c 100644 --- a/advtrains_interlocking/train_related.lua +++ b/advtrains_interlocking/train_related.lua @@ -73,6 +73,19 @@ local function setsection(tid, train, ts_id, ts, origin) table.insert(ts.trains, tid) end + -- route setting - clear route state + if ts.route then + if ts.route.first then + local tcbs = advtrains.interlocking.db.get_tcbs(ts.route.origin) + if tcbs then + --TODO callbacks + tcbs.routeset = nil + tcbs.route_committed = nil + end + end + ts.route = nil + end + end local function freesection(tid, train, ts_id, ts) @@ -84,6 +97,15 @@ local function freesection(tid, train, ts_id, ts) if not ts.trains then ts.trains = {} end itremove(ts.trains, tid) + if ts.route_post then + advtrains.interlocking.route.free_route_locks(ts_id, ts.route_post.locks) + if ts.route_post.next then + --this does nothing when the train went the right way, because + -- "route" info is already cleared. + advtrains.interlocking.route.cancel_route_from(ts.route_post.next) + end + ts.route_post = nil + end end |