From 919dbef9da1345a4c30f768ca99d63402dd606a3 Mon Sep 17 00:00:00 2001 From: autocommitter Date: Mon, 22 Apr 2024 14:52:38 +0200 Subject: State at 2021-04-04 --- init_code.lua | 453 +++++++++++++++++++++++++++++++++++++++++++++- nodes/(-1023,21,-108).lua | 1 + nodes/(-1023,21,-150).lua | 1 + nodes/(-1023,21,-190).lua | 1 + nodes/(-1023,21,-88).lua | 1 + nodes/(-1477,9,-83).lua | 29 +++ nodes/(-1481,3,1160).lua | 10 + nodes/(-2091,9,-4569).lua | 1 + nodes/(-640,14,-426).lua | 3 + nodes/(1103,23,3014).lua | 8 + nodes/(1103,23,3027).lua | 8 + nodes/(1106,19,3007).lua | 6 + nodes/(1106,23,1943).lua | 9 + nodes/(1107,16,1951).lua | 5 + nodes/(142,8,164).lua | 1 + nodes/(1524,21,2656).lua | 4 + nodes/(159,11,846).lua | 28 +++ nodes/(1604,-1,7982).lua | 10 + nodes/(1618,-1,7982).lua | 10 + nodes/(1725,28,2912).lua | 1 + nodes/(1730,26,2915).lua | 12 ++ nodes/(1730,26,2926).lua | 5 + nodes/(1734,26,2922).lua | 10 + nodes/(1899,19,8223).lua | 4 + nodes/(1932,8,9112).lua | 19 ++ nodes/(1936,7,9131).lua | 11 ++ nodes/(1953,19,8220).lua | 4 + nodes/(1971,5,7353).lua | 8 + nodes/(1973,42,8384).lua | 9 + nodes/(1973,5,6132).lua | 8 + nodes/(1976,5,7914).lua | 8 + nodes/(1977,3,7354).lua | 4 + nodes/(1980,3,6129).lua | 4 + nodes/(1980,3,7922).lua | 4 + nodes/(1980,41,8381).lua | 5 + nodes/(1980,41,8395).lua | 10 + nodes/(2648,13,4352).lua | 4 + nodes/(286,4,206).lua | 27 +++ nodes/(767,10,3484).lua | 10 + nodes/(790,8,-109).lua | 5 + nodes/(941,18,-571).lua | 5 + nodes/(957,14,1047).lua | 6 +- nodes/(960,14,1067).lua | 3 + nodes/(972,14,1053).lua | 5 +- 44 files changed, 777 insertions(+), 3 deletions(-) create mode 100644 nodes/(-1023,21,-108).lua create mode 100644 nodes/(-1023,21,-150).lua create mode 100644 nodes/(-1023,21,-190).lua create mode 100644 nodes/(-1023,21,-88).lua create mode 100644 nodes/(-1477,9,-83).lua create mode 100644 nodes/(-1481,3,1160).lua create mode 100644 nodes/(-2091,9,-4569).lua create mode 100644 nodes/(-640,14,-426).lua create mode 100644 nodes/(1103,23,3014).lua create mode 100644 nodes/(1103,23,3027).lua create mode 100644 nodes/(1106,19,3007).lua create mode 100644 nodes/(1106,23,1943).lua create mode 100644 nodes/(1107,16,1951).lua create mode 100644 nodes/(142,8,164).lua create mode 100644 nodes/(1524,21,2656).lua create mode 100644 nodes/(159,11,846).lua create mode 100644 nodes/(1604,-1,7982).lua create mode 100644 nodes/(1618,-1,7982).lua create mode 100644 nodes/(1725,28,2912).lua create mode 100644 nodes/(1730,26,2915).lua create mode 100644 nodes/(1730,26,2926).lua create mode 100644 nodes/(1734,26,2922).lua create mode 100644 nodes/(1899,19,8223).lua create mode 100644 nodes/(1932,8,9112).lua create mode 100644 nodes/(1936,7,9131).lua create mode 100644 nodes/(1953,19,8220).lua create mode 100644 nodes/(1971,5,7353).lua create mode 100644 nodes/(1973,42,8384).lua create mode 100644 nodes/(1973,5,6132).lua create mode 100644 nodes/(1976,5,7914).lua create mode 100644 nodes/(1977,3,7354).lua create mode 100644 nodes/(1980,3,6129).lua create mode 100644 nodes/(1980,3,7922).lua create mode 100644 nodes/(1980,41,8381).lua create mode 100644 nodes/(1980,41,8395).lua create mode 100644 nodes/(2648,13,4352).lua create mode 100644 nodes/(286,4,206).lua create mode 100644 nodes/(767,10,3484).lua create mode 100644 nodes/(790,8,-109).lua create mode 100644 nodes/(941,18,-571).lua create mode 100644 nodes/(960,14,1067).lua diff --git a/init_code.lua b/init_code.lua index 313075b..e44819e 100644 --- a/init_code.lua +++ b/init_code.lua @@ -37,4 +37,455 @@ end function F.timedisplay() digiline_send("time", "Time: | "..rwt.to_string(rwt.now(),true).." | "..os.date("%H:%M:%S")) schedule(rwt.next_rpt(rwt.now(),5,0), "") -end \ No newline at end of file +end + +-- Stat counter and timetaking utilities +-- Stat from subway +F.stat=function(line, init) +--statistics +-- init +if init then +reftrain = atc_id +a_tbt = 30 +a_tbtmax = 30 +a_rtt = 500 +a_not = 0 +c_not = 0 +c_tbtmax = 0 +time_lt = os.time() +time_rt=os.time() +end +if not a_tbtmax then a_tbtmax = 30 end +if not c_tbtmax then c_tbtmax = 0 end +--real code +if event.train then +local time = os.time() +c_not = c_not + 1 +a_tbt = (a_tbt + (time - time_lt)) / 2 +c_tbtmax = math.max(c_tbtmax, (time - time_lt)) +if atc_id == reftrain then + a_rtt = (a_rtt*0.2 + (time - time_rt)*0.8) + a_not = c_not + c_not = 0 + a_tbtmax = (a_tbtmax + c_tbtmax) / 2 + c_tbtmax = 0 +end + digiline_send("stats", "Stat: "..line.. + " NoT:"..a_not.."("..c_not..")".. + " TbT:"..math.floor(a_tbt).."("..(time-time_lt)..")".. + " Tmx:"..math.floor(a_tbtmax).."("..c_tbtmax..")".. + " R:"..math.floor(a_rtt).."("..(time - time_rt)..")" + ) +time_lt = time +if atc_id == reftrain then + time_rt = time +end +end +end + +S.timetake = {} +function F.timetake_start(ttname) + if not atc_id then return end + local nouw = rwt.to_secs(rwt.now()) + if not S.timetake[ttname] then + S.timetake[ttname] = {} + end + S.timetake[ttname][atc_id] = nouw +end + +--L100 +function F.timetake_end(ttname) + if not atc_id then return end + if not S.timetake[ttname] or not S.timetake[ttname][atc_id] then + digiline_send("timetake", "No start time for "..atc_id) + return + end + local first = S.timetake[ttname][atc_id] + local nouw = rwt.to_secs(rwt.now()) + local tdiff = nouw - first + local cavg = S.timetake[ttname].avg + local cmax = S.timetake[ttname].max + local cmin = S.timetake[ttname].min + if cavg and cmax and cmin then + S.timetake[ttname].avg = tdiff*0.1 + cavg*0.9 + S.timetake[ttname].min = math.min(tdiff, cmin) + S.timetake[ttname].max = math.max(tdiff, cmax) + else + S.timetake[ttname].avg = tdiff + S.timetake[ttname].min = tdiff + S.timetake[ttname].max = tdiff + end + digiline_send("timetake", ttname.. + " this:"..tdiff.. + " min:"..math.floor(S.timetake[ttname].min).. + " avg:"..math.floor(S.timetake[ttname].avg).. + " max:"..math.floor(S.timetake[ttname].max) + ) + +end + +--== Timetable prototype (TTP) === +--[[ table structures: +F.ttp - static timetable data - see below +S.ttp[tt_name] = { - dynamic tt data + recording_train = + travel_times = { + =