summaryrefslogtreecommitdiff
path: root/auto_yards/nodes/(417,17,4).lua
blob: b634cde9080e7e11b5267fdc07d40406fd3ec9f0 (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
if event.channel=="clock" then
	local yard_id = event.msg
	local info = S.yards[yard_id]
	digiline_send("rwt_clock","Rwt Now:\n"..rwt.to_string(rwt.now()))
	
	if not S.yards[yard_id] then
		digiline_send(yard_id.."_1",yard_id.." -- Not In Service")
		digiline_send(yard_id.."_2"," ")
		digiline_send(yard_id.."_NOTIFY"," ")
		return
	end
	
	local function getN(t)
		local count = 0
		for _ in pairs(t) do
			count = count+1
		end
		return count
	end
 
									  
	local txt = {}
	local txt2 = {}
	txt[#txt+1] = yard_id.." --"..info.yard_name.." Yard--"
	txt[#txt+1] = "Active:     " .. tostring(F.indicator(info.active_indicator_pos))
																																		
	txt[#txt+1] = "Direction:  " .. tostring(F.indicator(info.dir_indicator_pos))
	txt[#txt+1] = "Last Train: " .. tostring(info.last_id).." ("..tostring(info.arrival_length).."-"..tostring(info.departure_length)..")"
	txt2[#txt2+1] = "Time: "..tostring(rwt.to_string(info.arrival_time)).."+"..tostring(rwt.to_string(rwt.diff(info.arrival_time,info.departure_time)))
	digiline_send(yard_id.."_1",table.concat(txt,"\n"))



		
	txt2[#txt2+1] = "RTS:        "..tostring(info.rts)
	txt2[#txt2+1] = "Error:      ".. tostring(F.indicator(info.error_indicator_pos))
	txt2[#txt2+1] = ""
	digiline_send(yard_id.."_2",table.concat(txt2,"\n"))
	
	local notifications = ""
	if info.notify then
		local nt = ""
		if getN(info.notify) > 0 then
			nt = "Notify: "
			for k in pairs(info.notify) do
				nt = nt..k..", "
			end
		else
			nt = "Notify: No Notifications"
		end
		
		local st_len = 26
		if nt:len() > st_len then
			nt = nt:sub(1,st_len).."\n"..nt:sub(st_len+1)
		end
		notifications = nt
	else
		notifications = "Notify:     Not Enabled"
	end
	digiline_send(yard_id.."_NOTIFY",notifications)
	return
end