diff options
Diffstat (limited to 'Crossroads')
-rw-r--r-- | Crossroads/init_code.lua | 53 | ||||
-rw-r--r-- | Crossroads/nodes/(1083,19,3028).lua | 2 | ||||
-rw-r--r-- | Crossroads/nodes/(1219,9,1549).lua | 2 | ||||
-rw-r--r-- | Crossroads/nodes/(1232,9,1547).lua | 2 | ||||
-rw-r--r-- | Crossroads/nodes/(1702,12,914).lua | 3 | ||||
-rw-r--r-- | Crossroads/nodes/(1709,17,914).lua | 3 | ||||
-rw-r--r-- | Crossroads/nodes/(1755,27,943).lua | 2 | ||||
-rw-r--r-- | Crossroads/nodes/(1767,27,946).lua | 2 | ||||
-rw-r--r-- | Crossroads/nodes/(1773,5,994).lua | 2 | ||||
-rw-r--r-- | Crossroads/nodes/(1795,5,1000).lua | 2 | ||||
-rw-r--r-- | Crossroads/nodes/(1890,6,946).lua | 37 |
11 files changed, 82 insertions, 28 deletions
diff --git a/Crossroads/init_code.lua b/Crossroads/init_code.lua index aa4e66d..185eef7 100644 --- a/Crossroads/init_code.lua +++ b/Crossroads/init_code.lua @@ -7,6 +7,9 @@ III) ATL/CRT Bronze Line -- I) Common Functions if S.trains == nil then S.trains = {} end +if S.corrratio == nil then S.corrratio = 1 end +if S.corrratio > 1 then S.corrratio = 1 end +if S.corrratio <= 0 then S.corrratio = 1 end -- F.dst - Get summer time function F.dst() @@ -32,19 +35,24 @@ next = Next stop function F.stnbasic(stn, side, optime, reverse, acc, out, reventry, predepart, postdepart, next,track) if event.train then if atc_arrow then + local t_start = os.clock() local cmdstr="" + local corr = S.corrratio + local t_sched = ((optime or 15)+1)-- commented out due to trouble *corr if out~=nil then atc_set_text_outside(out) end - if stn==nil then atc_set_text_inside("Unknown Station") - else atc_set_text_inside(F.stnlist[stn]) end + local intext = "Unknown Station" + if stn and F.stnlist[stn] then intext = F.stnlist[stn] end + --intext = intext .. "\nCorrection: " .. S.corrratio + atc_set_text_inside(intext) cmdstr="BBWO"..(side or "R") if predepart~=nil then predepart() end S.trains[atc_id] = "P "..stn.." "..(track or "x") - cmdstr=cmdstr.."D"..(optime or 15) - cmdstr=cmdstr.."OCD2" + cmdstr=cmdstr.."D"..math.floor((optime or 15))-- comment out due to trouble *S.corrratio) + cmdstr=cmdstr.."OCD1" if reverse then cmdstr=cmdstr.."R" end cmdstr=cmdstr.."S"..(acc or "M") atc_send(cmdstr) - interrupt((optime or 15)+2) + interrupt(t_sched,{sched=t_sched,start=t_start,corr=corr}) else if reventry==nil then F.error("wrong_direction") else @@ -54,8 +62,18 @@ function F.stnbasic(stn, side, optime, reverse, acc, out, reventry, predepart, p end if event.int then if atc_id ~= nil then - if next == nil then atc_set_text_inside("") else atc_set_text_inside("Next stop: "..F.stnlist[next]) end + local intext = "" + if next ~= nil then intext = "Next stop: "..(F.stnlist[next] or "???") end if postdepart~=nil then postdepart() end + --[[ + if event.msg and event.msg.start and event.msg.sched and event.msg.corr then + local t_end = os.clock() + S.corrratio = event.msg.sched/event.msg.corr/(t_end-event.msg.start) + if S.corrratio > 1 then S.corrratio = 1 end + end + ]] + --atc_set_text_inside(intext.."\nCorrection: "..S.corrratio) + atc_set_text_inside(intext) end end end @@ -78,10 +96,9 @@ end -- F.timing - station with timing function F.timing(d_off, d_int, cur, nxt, side, spd, out, trk, term, pre, post) local timenow = os.time() - local timerdy = timenow + 8 - local wait = d_int - ((timerdy-d_off) % d_int) - local waitcorr = math.floor(wait*0.66) - F.stnbasic(cur, side, waitcorr, term, spd, out, true, pre, post, nxt, trk) + local timesincelast = (timenow+d_off) % d_int + local wait = d_int - timesincelast + F.stnbasic(cur, side, wait, term, spd, out, true, pre, post, nxt, trk) end -- F.brk(direction) - sends ATC B2 command @@ -130,15 +147,14 @@ F.stnlist = { crch = "Crossroads City Hall", crchs = "Crossroads City Hall South", crmtrail = "Crossroads Mountain Railway Termius", - crnsw = "CR-North Station St. Ferry (W.)", + crnsw = "CR-North Station St. 9th Alley", crrathaus = "Crossroads City Hall", crsmacker = "Crossroads Smacker's Station", crwm = "Crossroads-West Mountains", crzn = "Crossroads-Zentrum/Nordstadt", - el = "Erstaziland", - elchateau = "Chateau d'Erstazi", - elgp = "Erstaziland Greener Pastures", - elsf = "Erstaziland Salt Factory", + elchateau = "Erstaziland-Chateau d'Erstazi", + elgp = "Erstaziland-Greener Pastures", + elsf = "Erstaziland-Salt Factory", evo = "EVO", mushroom = "Mushroom Land", neverbuild = "Neverbuild", @@ -154,6 +170,7 @@ F.stnlist = { scc = "Silver Coast Central", scn = "Silver Coast North", scs = "Silver Coast South", + thecube = "The Cube", } F.errlist = { ["runaway_train"] = "Runaway train found!", @@ -172,7 +189,6 @@ F.depint = { -- Colored Grasses F.ab_cgw="--:-- "..F.dst() F.ab_cge="--:-- "..F.dst() - F.ab_status = "Irregular operation" F.cg_disp = function() @@ -180,14 +196,13 @@ F.cg_disp = function() if event.digiline then if not event.channel=="upd" then return end end local t=os.date() local cg="Colored Grasses\nATL/CRT Bronze Line\n" - local str = string.format("%s\n"..F.ab_status.." \n", os.date("%d %b %Y %H:%M %z",os.time())) - local abf = os.date("%H:%M %z",os.time()+60) + local str = string.format("%26s\n%26s\n",os.date("%Y-%m-%d %H:%M %z",os.time()),F.ab_status) digiline_send("bstg1-1",cg.."<-- Personhood West\n[1] via The Cube") digiline_send("bstg1-2",string.format("%s%27s\n%27s",str,"Crossroads City Hall -->","via Silver Coast [2]")) digiline_send("bstg2-1",cg.."<-- Crossroads City Hall\n[2] via Silver Coast") digiline_send("bstg2-2",string.format("%s%27s\n%27s",str,"Personhood West -->","via The Cube [1]")) digiline_send("bstg3","Scheduled departure (Track\nScheduled departure (Track") - digiline_send("bstg4","1): "..abf.."\n2): "..abf) + digiline_send("bstg4",os.date("1): %H:%M %z%n2): %H:%M %z",os.time()+60)) return end return diff --git a/Crossroads/nodes/(1083,19,3028).lua b/Crossroads/nodes/(1083,19,3028).lua index 0e5b482..20ba94c 100644 --- a/Crossroads/nodes/(1083,19,3028).lua +++ b/Crossroads/nodes/(1083,19,3028).lua @@ -1,5 +1,5 @@ if event.train then if not atc_arrow then return end - atc_set_text_outside("ATL/CRT Bronze Line - Crossroads City Hall") + atc_set_text_outside("ATL Bronze Line - Crossroads City Hall") set_line("AB") end
\ No newline at end of file diff --git a/Crossroads/nodes/(1219,9,1549).lua b/Crossroads/nodes/(1219,9,1549).lua index e08cb42..c54106a 100644 --- a/Crossroads/nodes/(1219,9,1549).lua +++ b/Crossroads/nodes/(1219,9,1549).lua @@ -1 +1 @@ -F.cg_stn(1)
\ No newline at end of file +F.timing(0,F.depint["AG"],"cg","thecube","R","M",nil,"1")
\ No newline at end of file diff --git a/Crossroads/nodes/(1232,9,1547).lua b/Crossroads/nodes/(1232,9,1547).lua index 4e4a905..32a814b 100644 --- a/Crossroads/nodes/(1232,9,1547).lua +++ b/Crossroads/nodes/(1232,9,1547).lua @@ -1 +1 @@ -F.cg_stn(2)
\ No newline at end of file +F.timing(0,F.depint["AG"],"cg","scn","R","M",nil,"1")
\ No newline at end of file diff --git a/Crossroads/nodes/(1702,12,914).lua b/Crossroads/nodes/(1702,12,914).lua index 27def93..4ce5b54 100644 --- a/Crossroads/nodes/(1702,12,914).lua +++ b/Crossroads/nodes/(1702,12,914).lua @@ -1 +1,2 @@ -F.hst("cras","crsmacker","L","M",nil,"1")
\ No newline at end of file +--F.hst("cras","crsmacker","L","M",nil,"1") +atc_send("SM")
\ No newline at end of file diff --git a/Crossroads/nodes/(1709,17,914).lua b/Crossroads/nodes/(1709,17,914).lua index 1375bd7..4b17b62 100644 --- a/Crossroads/nodes/(1709,17,914).lua +++ b/Crossroads/nodes/(1709,17,914).lua @@ -1 +1,2 @@ -F.hst("cras","crchs","R","M",nil,"2")
\ No newline at end of file +--F.hst("cras","crchs","R","M",nil,"2") +atc_send("SM")
\ No newline at end of file diff --git a/Crossroads/nodes/(1755,27,943).lua b/Crossroads/nodes/(1755,27,943).lua index 01ed586..eeaa266 100644 --- a/Crossroads/nodes/(1755,27,943).lua +++ b/Crossroads/nodes/(1755,27,943).lua @@ -51,7 +51,7 @@ if event.type=="digiline" then 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("lag1", "DEBUG\nTRAINS: " .. counter .. "\nDISPS: " .. length .. "\nTS: " .. os.time()) 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 diff --git a/Crossroads/nodes/(1767,27,946).lua b/Crossroads/nodes/(1767,27,946).lua index 27d996d..f30bb31 100644 --- a/Crossroads/nodes/(1767,27,946).lua +++ b/Crossroads/nodes/(1767,27,946).lua @@ -1,2 +1,2 @@ S.trains = {} -S.lagavg = {}
\ No newline at end of file +S.lagrec = {}
\ No newline at end of file diff --git a/Crossroads/nodes/(1773,5,994).lua b/Crossroads/nodes/(1773,5,994).lua index 575cb88..a44cbcf 100644 --- a/Crossroads/nodes/(1773,5,994).lua +++ b/Crossroads/nodes/(1773,5,994).lua @@ -1 +1 @@ -F.timing(0, F.depint["AB"], "crch", "crwm", "R", "M", "ATL/CRT Bronze Line - Personhood West", "1", true)
\ No newline at end of file +F.timing(0, F.depint["AB"], "crch", "crwm", "R", "M", "ATL Bronze Line - Personhood West", "1", true)
\ No newline at end of file diff --git a/Crossroads/nodes/(1795,5,1000).lua b/Crossroads/nodes/(1795,5,1000).lua index ccf3e26..d5beb66 100644 --- a/Crossroads/nodes/(1795,5,1000).lua +++ b/Crossroads/nodes/(1795,5,1000).lua @@ -1,5 +1,5 @@ if event.type == "train" then if atc_arrow then - atc_set_text_inside("Next stop: CR-North Station St. Ferry (West)") + atc_set_text_inside("Next stop: CR-North Station St. 9th Alley") end end
\ No newline at end of file diff --git a/Crossroads/nodes/(1890,6,946).lua b/Crossroads/nodes/(1890,6,946).lua new file mode 100644 index 0000000..7f023d4 --- /dev/null +++ b/Crossroads/nodes/(1890,6,946).lua @@ -0,0 +1,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
\ No newline at end of file |