blob: 4fe8b87017a54c233a0c7677e6819ae41d83b46f (
plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
-- environment_ers.lua
F.debug = true
F.isempty = function (s)
return s == nil or s == ''
end
F.print = function (str)
if F.debug then
print("PrntMsg: ".. (str or "nil") )
end
end
S.train_duration = {}
F.train_duration = function(type)
if not atc_id then return end
local now = os.date("%H:%M:%S")
if F.isempty(type) then
type = "start"
end
if not S.train_duration[atc_id] then
S.train_duration[atc_id] = { ["train_id"] = atc_id, ["start"] = "", ["end"] = "" }
end
if type == "start" then
S.train_duration[atc_id]["end"] = "Nil"
end
S.train_duration[atc_id][type] = now
end
F.train_info = function (passive_name, show_print)
local timestart = ""
local timeend = ""
local time_message = ""
if F.isempty(passive_name) or passive_name == "RESETALL" then
msg_atc_id = "No Train"
if passive_name == "RESETALL" then
S.train_duration = {}
end
else
timestart = S.train_duration[atc_id]["start"]
timeend = S.train_duration[atc_id]["end"]
msg_atc_id = atc_id
end
local lcd_message = "" ..
msg_atc_id ..
""
if not F.isempty(timestart) and not F.isempty(timeend) then
time_message = "Time: | " .. timestart .. " to " .. timeend
elseif not F.isempty(timestart) and F.isempty(timeend) then
time_message = "Start Time: | " .. timestart
else
time_message = "RegTime: | " .. os.date("%H:%M:%S")
end
digiline_send("lcd", lcd_message)
digiline_send("time", time_message)
local message = lcd_message .. " | " .. time_message
if show_print == true then
F.print(message)
end
end
F.does_train_have_rc = function(wanted_rc)
local rc = get_rc() or ""
if rc:match(wanted_rc) then
return true
else
return false
end
end
F.send_route = function(passive_name, route, show_print)
if can_set_route(passive_name, route) then
set_route(passive_name, route)
if show_print == true then
F.print(passive_name .. " has been set to " .. route)
end
return true
else
if show_print == true then
F.print(route .. " cannot be set for " .. passive_name .. ". Try another")
end
return false
end
end
if event.type == "init" then
F.print("Initialized")
end
|