diff options
author | autocommitter <autocommitter@linux-forks.de> | 2024-04-22 14:51:45 +0200 |
---|---|---|
committer | autocommitter <autocommitter@linux-forks.de> | 2024-04-22 14:51:45 +0200 |
commit | 0b14726c5539782a60d2f4beaed2cfca74a50f7a (patch) | |
tree | 1de6e16c565f7bb9806552fc587d7eac870b6b00 /Crossroads/nodes/(1755,27,943).lua | |
download | luaatc_envs-0b14726c5539782a60d2f4beaed2cfca74a50f7a.tar.gz luaatc_envs-0b14726c5539782a60d2f4beaed2cfca74a50f7a.tar.bz2 luaatc_envs-0b14726c5539782a60d2f4beaed2cfca74a50f7a.zip |
State at 2019-12-13
Diffstat (limited to 'Crossroads/nodes/(1755,27,943).lua')
-rw-r--r-- | Crossroads/nodes/(1755,27,943).lua | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Crossroads/nodes/(1755,27,943).lua b/Crossroads/nodes/(1755,27,943).lua new file mode 100644 index 0000000..01ed586 --- /dev/null +++ b/Crossroads/nodes/(1755,27,943).lua @@ -0,0 +1,57 @@ +local head="TRAIN STATUS" +local function trainpairs(t, f) + local a = {} + for n in pairs(t) do table.insert(a, n) end + table.sort(a, f) + local i = 0 + local iter = function () + i = i + 1 + if a[i] == nil then return nil + else return a[i], t[a[i]] + end + end + return iter +end +local length = 18 +if event.type=="digiline" then + if event.channel=="upd_main" then + local start_t = os.clock() + if not S.lagrec then S.lagrec = {} end + local l = {} + local i + for i=1,length,1 do + if i%2 == 0 then + l[i]="" + else + l[i]=head + end + end + local counter=0 + for id,st in trainpairs(S.trains) do + if (counter) % 7 < 3 then + i = (counter - counter % 7) / 7 * 2 + 1 + else + i = (counter - counter % 7) / 7 * 2 + 2 + end + l[i] = l[i] .. "\n" .. id .. " " .. st + counter = counter + 1 + end + for i=1,length,1 do + if l[i]=="" then + digiline_send("d"..tostring(i),"...") + else + digiline_send("d"..tostring(i),l[i]) + end + end + local end_t = os.clock() + table.insert(S.lagrec,end_t - start_t) + table.sort(S.lagrec) + local lagavg = 0 + for _,v in pairs(S.lagrec) do + lagavg = lagavg + v + end + lagavg = lagavg / #S.lagrec + digiline_send("lag1", "DEBUG\nTRAINS: " .. counter .. "\nDISPS: " .. length .. "\nTIME: " .. os.date("%d %b %Y %X")) + digiline_send("lag2", "CUR " .. (end_t - start_t) .. "\nMIN " .. S.lagrec[1] .. "\nMAX " .. S.lagrec[#S.lagrec] .. "\nAVG " .. lagavg) + end +end
\ No newline at end of file |