summaryrefslogtreecommitdiff
path: root/Crossroads/nodes/(1890,6,946).lua
blob: 7f023d4f7c55607ac3e5f3c1eef6c521308d2ca8 (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
local atdiff = 5
if not S.corrcalc then S.corrcalc = {} end
if S.corrcalc.lasttime then S.corrcalc.lasttime = nil end
if event.type == "punch" then
  S.corrcalc.lastrlt = os.time()
  S.corrcalc.lastrwt = rwt.to_secs(rwt.now())
  digiline_send("name","1SE | Time calculation")
end
if event.type == "digiline" and event.msg == "recalc" then
  if not (S.corrcalc.lastrlt and S.corrcalc.lastrwt) then
    S.corrcalc.lastrlt = os.time()
    S.corrcalc.lastrwt = rwt.to_secs(rwt.now())
  else
    local nowrlt = os.time()
    local nowrwt = rwt.to_secs(rwt.now())
    local nowtbl = rwt.now()
    local rltdiff = nowrlt - S.corrcalc.lastrlt
    local rwtdiff = nowrwt - S.corrcalc.lastrwt
    digiline_send("disp0", string.format("RLT: %d | RWT: %d %d;%02d;%02d", nowrlt, nowrwt, nowtbl.c, nowtbl.m, nowtbl.s))
    digiline_send("disp1", string.format("DIFF: %d/%d | RLT/RWT: %.4f | RWT/RLT: %.4f", rltdiff, rwtdiff, rltdiff/rwtdiff, rwtdiff/rltdiff))
    S.corrcalc.lastrlt = nowrlt
    S.corrcalc.lastrwt = nowrwt
    interrupt(atdiff, {os.clock(), nowrwt})
  end
end
if event.type == "int" then
  local nowrlt = os.clock()
  local nowrwt = rwt.to_secs(rwt.now())
  local lastrlt = (event.msg and event.msg[1]) or S.corrcalc.lastrlt
  local lastrwt = (event.msg and event.msg[2]) or S.corrcalc.lastrwt
  local rltdiff = nowrlt - lastrlt
  local rwtdiff = nowrwt - lastrwt
  digiline_send("disp2", string.format("CPU: %.4f ------------ | RWT: | %d", nowrlt, nowrwt))
  digiline_send("disp3", string.format("RLT Diff: | %.4f | RWT Diff: | %d | AT Diff: %d", rltdiff, rwtdiff, atdiff))
  digiline_send("disp4", string.format("RLT/AT | %.4f | AT/RLT | %.4f", rltdiff/atdiff, atdiff/rltdiff))
  digiline_send("disp5", string.format("RWT/AT | %.4f | AT/RWT | %.4f", rwtdiff/atdiff, atdiff/rwtdiff))
end