aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking/database.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-07-04 17:48:33 +0200
committerorwell96 <orwell@bleipb.de>2018-07-04 17:48:33 +0200
commit031aab4633f6f140a2ffda4f00b6e0d743cf681a (patch)
treed43a3e7fac033676969a34ad45e81b7db105448b /advtrains_interlocking/database.lua
parent9586a4d70922e24ba45ef018fc48455f31c4cfbb (diff)
downloadadvtrains-031aab4633f6f140a2ffda4f00b6e0d743cf681a.tar.gz
advtrains-031aab4633f6f140a2ffda4f00b6e0d743cf681a.tar.bz2
advtrains-031aab4633f6f140a2ffda4f00b6e0d743cf681a.zip
Signal assignment and route programming procedure
Diffstat (limited to 'advtrains_interlocking/database.lua')
-rw-r--r--advtrains_interlocking/database.lua26
1 files changed, 25 insertions, 1 deletions
diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua
index f4a6871..6c6047f 100644
--- a/advtrains_interlocking/database.lua
+++ b/advtrains_interlocking/database.lua
@@ -95,6 +95,8 @@ local ildb = {}
local track_circuit_breaks = {}
local track_sections = {}
+local signal_assignments = {}
+
function ildb.load(data)
if not data then return end
if data.tcbs then
@@ -103,10 +105,13 @@ function ildb.load(data)
if data.ts then
track_sections = data.ts
end
+ if data.signalass then
+ signal_assignments = data.signalass
+ end
end
function ildb.save()
- return {tcbs = track_circuit_breaks, ts=track_sections}
+ return {tcbs = track_circuit_breaks, ts=track_sections, signalass = signal_assignments}
end
--
@@ -123,6 +128,7 @@ TCB data structure
-- while the signal still displays danger and nothing is written to the TCs
-- As soon as the route can actually be set, all relevant TCs and turnouts are set and this field
-- is set true, clearing the signal
+ aspect = <asp> -- The aspect the signal should show. If this is nil, should show the most restrictive aspect (red)
},
[2] = { -- Variant: end of track-circuited area (initial state of TC)
ts_id = nil, -- this is the indication for end_of_interlocking
@@ -145,6 +151,11 @@ Track section
Signal specifier (sigd) (a pair of TCB/Side):
{p = <pos>, s = <1/2>}
+
+Signal Assignments: reverse lookup of signals assigned to TCBs
+signal_assignments = {
+[<signal pts>] = <sigd>
+}
]]
@@ -406,6 +417,19 @@ function ildb.get_ts_at_pos(pos)
return nil
end
+
+-- returns the sigd the signal at pos belongs to, if this is known
+function ildb.get_sigd_for_signal(pos)
+ local pts = advtrains.roundfloorpts(pos)
+ return signal_assignments[pts]
+end
+function ildb.set_sigd_for_signal(pos, sigd)
+ local pts = advtrains.roundfloorpts(pos)
+ signal_assignments[pts] = sigd
+end
+
+
+
advtrains.interlocking.db = ildb