From 5c7f77725394d47ce0b907aabf885ea207a507bd Mon Sep 17 00:00:00 2001 From: autocommitter Date: Tue, 15 Oct 2024 22:37:32 +0200 Subject: State at 2024-10-15 --- il_timetable/init_code.lua | 93 ++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 32 deletions(-) (limited to 'il_timetable/init_code.lua') diff --git a/il_timetable/init_code.lua b/il_timetable/init_code.lua index 70d25e4..322b0a4 100644 --- a/il_timetable/init_code.lua +++ b/il_timetable/init_code.lua @@ -147,8 +147,11 @@ S.ttt[train_id] = { - trains ]] local STOP_TIME = 10 +local STOPCMD="B0WO" local DEPCMD="A1OCD1SM" local RDEPCMD="RA1OCD1SM" +local DYNAMIC_THR = 10 +local DYNAMIC_EN = false if not S.ttp then S.ttp = {} end if not S.ttt then S.ttt = {} end @@ -161,7 +164,7 @@ F.ttp={ CFE_S = { outside_text = "[CFE] Origin\nvia Crystal Farms, Personhood West, Ehlodex", inside_line_desc = "CFE to Origin", - stn_display = "CFE Origin ", + stn_display = "CFE Origin North", }, NRG_E = { outside_text = "[NRG] Azena Transirejo", @@ -203,35 +206,35 @@ F.ttp={ inside_line_desc = "S12 to Silver Coast", stn_display = "S12 Silver Coast", }, - E84_N = { - outside_text = "[E84] Namespace Mountains", - inside_line_desc = "E84 to Namespace Mountains", - stn_display = "E84 Namespace M.", - }, - E84_S = { - outside_text = "[E84] Personhood Main", - inside_line_desc = "E84 to Personhood Main", - stn_display = "E84 Personhood ", - }, E85_N = { - outside_text = "[E85] Namespace Mountains", - inside_line_desc = "E85 to Namespace Mountains", - stn_display = "E85 Namespace M.", + outside_text = "[BAK] Namespace Mountains", + inside_line_desc = "Baka Express (BAK) to Namespace Mountains", + stn_display = "BAK Namespace M.", }, E85_S = { - outside_text = "[E85] BRIC / Morija North", - inside_line_desc = "E85 to BRIC / Morija North", - stn_display = "E85 BRIC/Morija ", + outside_text = "[BAK] Morija North", + inside_line_desc = "Baka Express (BAK) to Morija North", + stn_display = "BAK Morija North", }, E11_E = { - outside_text = "[E11] Oasis", - inside_line_desc = "E11 to Oasis", - stn_display = "E11 Oasis ", + outside_text = "[OEX] Oasis", + inside_line_desc = "OEX to Oasis", + stn_display = "OEX Oasis ", }, E11_W = { - outside_text = "[E11] Personhood", - inside_line_desc = "E11 to Personhood", - stn_display = "E11 Personhood ", + outside_text = "[OEX] Personhood", + inside_line_desc = "OEX to Personhood", + stn_display = "OEX Personhood ", + }, + E16_E = { + outside_text = "[E16] Cat-o-Land (By The Way)\nC&C Rail", + inside_line_desc = "E16 to Cat-o-Land (By The Way)", + stn_display = "E16 Cat-o-Land ", + }, + E16_W = { + outside_text = "[E16] Personhood\nC&C Rail", + inside_line_desc = "E16 to Personhood", + stn_display = "E16 Personhood ", }, } @@ -255,7 +258,11 @@ function F.ttp_begin(p) __approach_callback_mode = 1 if not F.ttp[p.tt] then error("No TT instance "..p.tt) end - if not atc_id or not atc_arrow then return end + if not atc_id then + print(p.stn,"missing train!",event) + return + end + if not atc_arrow then return end if p.only_lines and not p.only_lines[get_line()] then return end if not S.ttp[p.tt] then S.ttp[p.tt] = {} end local tti = S.ttp[p.tt] @@ -268,7 +275,7 @@ function F.ttp_begin(p) end if event.train then -- train arrived, planning departure - atc_send("B0 W O"..p.doorside) + atc_send(STOPCMD..p.doorside) local time_now = rwt.now() -- Train might have had another TT before, do the cleanup from ttp_end here. @@ -339,7 +346,10 @@ F.ttp_stop({ ]]function F.ttp_stop(p) -- set my approach callback mode __approach_callback_mode = 1 - if not atc_id or not atc_arrow then return end + if not atc_id then + print(p.stn,"missing train!",event) + return + end if not S.ttt[atc_id] then return end if p.only_lines and not p.only_lines[get_line()] then return end local trn = S.ttt[atc_id] @@ -356,9 +366,17 @@ F.ttp_stop({ atc_set_lzb_tsr(2) atc_set_text_inside("Next stop: "..p.stn) end + +--!-- disaster recovery --!-- +-- if event.approach and event.has_entered then +-- print(atc_id,p.stn,"Disaster Recovery...") +-- atc_send(DEPCMD) +-- end + + if event.train then -- train arrived, planning departure - atc_send("B0 W O"..p.doorside) + atc_send(STOPCMD..p.doorside) local time_now = rwt.now() -- update our location and determine desired and planned departure --L200 @@ -374,6 +392,17 @@ F.ttp_stop({ elseif tti.travel_times[p.stn] then trn.desired_dep = rwt.add(trn.initial_dep or 0, tti.travel_times[p.stn] + STOP_TIME) + -- dyn travel time + if DYNAMIC_EN then + local ttpd = rwt.diff(next_dep_time, trn.desired_dep) + if ttpd > DYNAMIC_THR then + local new_trav = rwt.diff(trn.initial_dep, time_now) + DYNAMIC_THR + print(atc_id,tt,"arrived at",p.stn,ttpd,"s early, TT",tti.travel_times[p.stn],"->",new_trav) + tti.travel_times[p.stn] = new_trav + trn.desired_dep = rwt.add(trn.initial_dep or 0, + new_trav + STOP_TIME) + end + end end if trn.desired_dep then @@ -435,11 +464,11 @@ function F.ttp_info_times(tt, starttime) if tti.recording_train then p[#p+1] = ("recording "..tti.recording_train) end - p[#p+1] = ("Di "..rwt.to_string(starttime, true).." "..tti.station_order[1]) + p[#p+1] = ("Di "..rwt.to_string(starttime, false).." "..tti.station_order[1]) for i=2,#tti.station_order do local ap = rwt.add(starttime, tti.travel_times[tti.station_order[i]]) p[#p+1] = ("Ap "..rwt.to_string(ap, true).. - " Dp "..rwt.to_string(rwt.add(ap, STOP_TIME), true).. + " Dp "..rwt.to_string(rwt.add(ap, STOP_TIME), false).. " "..tti.station_order[i]) end return p @@ -454,13 +483,13 @@ function F.ttp_info_trains(tt, starttime) if trn.actual_dep then p[#p+1] = ("Trn "..tid.. " after "..trn.location.. - " Dd "..rwt.to_string(trn.desired_dep or 0, true).. - " Da "..rwt.to_string(trn.actual_dep, true).. + " Dd "..rwt.to_string(trn.desired_dep or 0, false).. + " Da "..rwt.to_string(trn.actual_dep, false).. " Delay "..rwt.to_string(trn.last_delay or "59;59")) else p[#p+1] = ("Trn "..tid.. " at "..trn.location.. - " Dd "..rwt.to_string(trn.desired_dep or 0, true).. + " Dd "..rwt.to_string(trn.desired_dep or 0, false).. " Delay "..rwt.to_string(trn.last_delay or "59;59")) end end -- cgit v1.2.3