fix(nbt): unwrap single-element arrays in CRN BlockReader NBT parsing (Station[1]/RealTimeStation[1]/ScheduledStation[1]/StationInfo[1]/Train[1]) to get real TrainName/Destination/StationName/Platform; fallback destination to precise StationName code (e.g. CE-03 2) when Destination is invalid or is CRN aggregated tag name. Bump to v1.0.74
This commit is contained in:
+39
-6
@@ -1,6 +1,6 @@
|
||||
|
||||
-- 1. Configuration & Constants
|
||||
local APP_VERSION_TEXT = "v1.0.73"
|
||||
local APP_VERSION_TEXT = "v1.0.74"
|
||||
|
||||
local CONFIG = {
|
||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||
@@ -3426,17 +3426,50 @@ function Main.loop()
|
||||
cleanupTimestampMap(State.announcedAlerts, now, tonumber(CONFIG.ALERT_COOLDOWN_MS) or 300000)
|
||||
|
||||
for i, stop in ipairs(data.TrainStops) do
|
||||
local st = stop.Station
|
||||
local st = type(stop.Station) == "table" and stop.Station[1] or stop.Station
|
||||
if st then
|
||||
local trainName = st.TrainName or "Unknown"
|
||||
local rtStation = type(st.RealTimeStation) == "table" and st.RealTimeStation[1] or nil
|
||||
local schStation = type(st.ScheduledStation) == "table" and st.ScheduledStation[1] or nil
|
||||
local rtStationName = rtStation and rtStation.StationName or nil
|
||||
local schStationName = schStation and schStation.StationName or nil
|
||||
local isLast = (stop.IsLast == 1 or stop.IsLast == true)
|
||||
|
||||
local destination = st.Destination or "Unknown"
|
||||
if type(stop.Stopovers) == "table" and #stop.Stopovers > 0 then
|
||||
destination = stop.Stopovers[#stop.Stopovers] or destination
|
||||
local lastStopover = stop.Stopovers[#stop.Stopovers]
|
||||
if looksLikeValidDestinationText(lastStopover) then
|
||||
destination = lastStopover
|
||||
else
|
||||
if looksLikeValidDestinationText(destination) then
|
||||
else
|
||||
destination = lastStopover or destination
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not looksLikeValidDestinationText(destination) and isLast then
|
||||
if looksLikeValidDestinationText(rtStationName) then
|
||||
destination = rtStationName
|
||||
elseif looksLikeValidDestinationText(schStationName) then
|
||||
destination = schStationName
|
||||
end
|
||||
end
|
||||
if not looksLikeValidDestinationText(destination) then
|
||||
if looksLikeValidDestinationText(rtStationName) then
|
||||
destination = rtStationName
|
||||
elseif looksLikeValidDestinationText(schStationName) then
|
||||
destination = schStationName
|
||||
end
|
||||
end
|
||||
|
||||
local platform = "1"
|
||||
if st.ScheduledStation and st.ScheduledStation.StationInfo and st.ScheduledStation.StationInfo.Platform then
|
||||
platform = st.ScheduledStation.StationInfo.Platform
|
||||
local rtStationInfo = rtStation and type(rtStation.StationInfo) == "table" and rtStation.StationInfo[1] or nil
|
||||
local schStationInfo = schStation and type(schStation.StationInfo) == "table" and schStation.StationInfo[1] or nil
|
||||
if schStationInfo and schStationInfo.Platform then
|
||||
platform = schStationInfo.Platform
|
||||
elseif rtStationInfo and rtStationInfo.Platform then
|
||||
platform = rtStationInfo.Platform
|
||||
else
|
||||
platform = State.stationPlatform or "1"
|
||||
end
|
||||
@@ -3444,7 +3477,7 @@ function Main.loop()
|
||||
if isStationDestination(destination) then
|
||||
local cancelled = false
|
||||
local reason = nil
|
||||
local tr = stop.Train
|
||||
local tr = type(stop.Train) == "table" and stop.Train[1] or stop.Train
|
||||
if tr then
|
||||
cancelled = tr.Cancelled == 1 or tr.Cancelled == true
|
||||
local status = tr.Status
|
||||
|
||||
Reference in New Issue
Block a user