1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
--
local delta = 4*60+20 -- HERE IS THE VALUE
local owdata = S.BaHi_T6
local numval = 5
local switchbox_cp = { x=-2221,y=14,z=297}
function save_delay(d)
if not owndata then
owndata = { false, false, false, false, false, false, false, false, }
end
for i=numval,2,-1 do
owndata[i] = owndata[i-1]
end
owndata[1] = d
end
function delay_text()
if not owndata then
return ""
end
local rg = ""
for i=1,numval do
h = owndata[i]
if not h then h = "" end
rg = rg .. h .." "
end
return rg
end
if event.type == "train" then
if atc_arrow then
atc_send("B0WOL") -- D20OCD3S2")
-- setstate("BaHi_T5_S2","st")
-- setstate("BaHi_T5_S1","st")
if not S.BaHi_T6 then
S.BaHi_T6 = os.time()
end
-- interrupt(1,"departure")
-- else
now = os.time()
tempdist = now-S.BaHi_T6
save_delay(tempdist)
delaystr = delay_text()
output = "last: "..S.BaHi_T6 .. "\nnow: " .. now .. "\ndelta: " .. tempdist.. "\n"..delta .. " " .. delaystr
digiline_send("lcd",output)
interrupt_pos( switchbox_cp, { action = "display", data = output } )
if tempdist > delta then
interrupt(15,"departure")
else
interrupt(-tempdist+delta,"departure")
end
-- end
end
return
end
if event.type == "int" then
if event.msg == "departure" then
-- setstate("BaHi_T5_S2","st")
-- setstate("BaHi_T5_S1","st")
atc_set_text_inside("S23 -> Redwood")
atc_send("ROCD3S2")
now = os.time()
delaystr = delay_text()
-- digiline_send("lcd","last: \nnow: " .. now .. "\ndelta: " .. tempdist.. "\n"..delta .. " " .. delaystr)
output = "last: " .. now .. " \n \n \n"..delta.." "..delaystr
digiline_send("lcd",output )
interrupt_pos( switchbox_cp, { action = "display", data = output } )
S.BaHi_T6 = now
end
return
end
|