debug: compare text and NBT ETA keys on monitor

This commit is contained in:
2026-08-02 17:00:24 +08:00
parent 4b95c86af6
commit 9f2dc5bb3d
2 changed files with 65 additions and 3 deletions
+24
View File
@@ -0,0 +1,24 @@
# Debug Session: eta-stopover-bug
- **Status**: [OPEN]
- **Issue**: 列车进站 ETA 仍然包含停站时间;终点站显示已正确,但 ETA 仍偏大。
- **Debug Server**: N/A
- **Log File**: N/A
## Reproduction Steps
1. 在发车牌和 Block Reader 都正常连接的情况下运行 `station_broadcast.lua`
2. 观察 `UPCOMING TRAINS` 的 ETA
3. 与 CRN 发车牌原始 ETA 对比
## Hypotheses & Verification
| ID | Hypothesis | Likelihood | Effort | Evidence |
|----|------------|------------|--------|----------|
| A | NBT 侧生成的 `announceKey` 仍未与 `create_target` 文本键完全匹配,导致没有走文本 ETA 覆盖 | High | Low | Pending |
| B | `create_target` 文本里解析出的 ETA 本身就是“到发后/含停站”的字段,而不是进站前 ETA | Medium | Low | Pending |
| C | 文本解析到了正确 ETA,但后来又被 NBT 计算值覆盖 | Medium | Low | Pending |
| D | 同一班车在 NBT 与文本中的目的地/车次格式仍有额外差异(空格、平台、后缀) | High | Low | Pending |
## Log Evidence
- Pending instrumentation
## Verification Conclusion
- Pending
+41 -3
View File
@@ -2149,7 +2149,28 @@ function Display.render()
)
if #dbgLine > w then dbgLine = dbgLine:sub(1, w) end
mon.write(dbgLine)
logsStartY = upcomingStartY + 2
if upcomingStartY + 2 <= h then
mon.setCursorPos(1, upcomingStartY + 2)
local keyLine = string.format(
"TK:%s NK:%s",
tostring(dbg.textKey or "-"),
tostring(dbg.nbtKey or "-")
)
if #keyLine > w then keyLine = keyLine:sub(1, w) end
mon.write(keyLine)
end
if upcomingStartY + 3 <= h then
mon.setCursorPos(1, upcomingStartY + 3)
local etaLine = string.format(
"TXT:%s NBT:%s USE:%s",
tostring(dbg.textEta or "-"),
tostring(dbg.nbtEta or "-"),
tostring(dbg.usedEta or "-")
)
if #etaLine > w then etaLine = etaLine:sub(1, w) end
mon.write(etaLine)
end
logsStartY = upcomingStartY + 4
end
if hasUpcoming then
mon.setTextColor(COLORS.INFO)
@@ -2337,7 +2358,12 @@ function Main.loop()
hasCT = Peripherals.createTarget ~= nil,
ok = false,
trainStopsCount = 0,
tickRate = State.tickRate or 20
tickRate = State.tickRate or 20,
textKey = nil,
nbtKey = nil,
textEta = nil,
nbtEta = nil,
usedEta = nil
}
-- Prefer CRN's own ETA display text (create_target) when available.
@@ -2373,7 +2399,12 @@ function Main.loop()
end
end
if dest then
etaByText[tName .. "_" .. dest] = etaSeconds
local textKey = tName .. "_" .. dest
etaByText[textKey] = etaSeconds
if not dbg.textKey then
dbg.textKey = textKey
dbg.textEta = etaSeconds
end
end
end
end
@@ -2459,10 +2490,17 @@ function Main.loop()
local etaSeconds = math.floor(etaTicks / (State.tickRate or 20))
if etaSeconds < 0 then etaSeconds = 0 end
local announceKey = trainName .. "_" .. destination
if not dbg.nbtKey then
dbg.nbtKey = announceKey
dbg.nbtEta = etaSeconds
end
local textEta = etaByText[announceKey]
if type(textEta) == "number" and textEta >= 0 then
etaSeconds = textEta
end
if not dbg.usedEta then
dbg.usedEta = etaSeconds
end
-- Calculate Delay in minutes
local delayTicks = realArrival - scheduledArrival