diff --git a/station_broadcast.lua b/station_broadcast.lua index deffaee..c9bcb76 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.68" +local APP_VERSION_TEXT = "v1.0.69" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group", @@ -3480,6 +3480,34 @@ function Main.loop() State.currentTrain = nil end end + + if State.currentTrain then + local ctKey = normalizeUpcomingKey(State.currentTrain.id, State.currentTrain.dest) + local alreadyInUpcoming = false + for _, ut in ipairs(State.upcomingTrains) do + local utKey = normalizeUpcomingKey(ut.trainName, ut.dest) + if utKey == ctKey then + alreadyInUpcoming = true + break + end + end + if not alreadyInUpcoming then + local nowSec = os.epoch("utc") / 1000 + local remaining = State.currentTrain.departureTime and math.max(0, State.currentTrain.departureTime - nowSec) or 0 + table.insert(State.upcomingTrains, 1, { + trainName = State.currentTrain.id, + dest = State.currentTrain.dest, + platform = State.currentTrain.platform or State.stationPlatform or "1", + eta = 0, + etaLabel = buildEtaLabel(0, nil), + delay = 0, + cancelled = false, + reason = nil, + _atStation = true, + _departingIn = remaining + }) + end + end Display.render() Display.renderTerminal()