From f922ace1546da575c7fce8c67af1c435e65c8512 Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Sun, 2 Aug 2026 17:42:49 +0800 Subject: [PATCH] fix: trigger approaching broadcast under 30 seconds --- CloudServer/server.js | 27 +++++++++++++++++++-------- station_broadcast.lua | 8 ++++---- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CloudServer/server.js b/CloudServer/server.js index b6b147c..5d044b1 100644 --- a/CloudServer/server.js +++ b/CloudServer/server.js @@ -1866,8 +1866,9 @@ function handleTrainApproaching(ws, data) { const finalPlatform = cleanPlatform || '1'; const destCode = data.destCode || getStationCodeFromName(data.destination) || 'UNK'; + const delay = Number(data.delay) || 0; // 获取延误信息(分钟) - log('INFO', `Train ${trainId} approaching ${stationName}. Broadcasting pre-arrival...`); + log('INFO', `Train ${trainId} approaching ${stationName} (Delay: ${delay} min). Broadcasting pre-arrival...`); ws.send(JSON.stringify({ type: 'train_approaching_ack', @@ -1880,11 +1881,21 @@ function handleTrainApproaching(ws, data) { // 提示音:ksts // 日文:ja-fc1 + ja-站台编号 + ja-fc2 + ja-终点编号 + ja-fc3 // 中文:ch-fc1 + ch-fc2 + ch-fc3 + ch-终点编号 + ch-fc4 - const seq = [ - 'ksts', - 'ja-fc1', `ja-${finalPlatform}`, 'ja-fc2', `ja-${destCode}`, 'ja-fc3', - 'ch-fc1', 'ch-fc2', 'ch-fc3', `ch-${destCode}`, 'ch-fc4' - ]; + const seq = ['ksts']; + + // 拼接日文 + seq.push('ja-fc1', `ja-${finalPlatform}`, 'ja-fc2', `ja-${destCode}`, 'ja-fc3'); + if (delay > 0) { + // TODO: 根据用户的延误音频设计在这里插入日文延误播报 + // 例如: seq.push('ja-delay-prefix', `ja-${delay}`, 'ja-delay-suffix'); + } + + // 拼接中文 + seq.push('ch-fc1', 'ch-fc2', 'ch-fc3', `ch-${destCode}`, 'ch-fc4'); + if (delay > 0) { + // TODO: 根据用户的延误音频设计在这里插入中文延误播报 + // 例如: seq.push('ch-delay-prefix', `ch-${delay}`, 'ch-delay-suffix'); + } enqueueHlsPush(stationName, seq); @@ -1896,8 +1907,8 @@ function handleTrainApproaching(ws, data) { sourcePath: built.sourcePath, streamUrl: built.streamUrl, durationSec: built.durationSec, - priority: 1, - interruptMode: 'ifLower', + priority: 0, + interruptMode: 'none', source: 'train_approaching', audioId, consoleStreamStart: { type: 'stream_start', station: stationName, seq, streamName: getStationStreamName(stationName), hlsUrl: getStationHlsUrl(getStationStreamName(stationName)) }, diff --git a/station_broadcast.lua b/station_broadcast.lua index d0ff0c4..8f34b94 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -2,7 +2,7 @@ -- ============================================================================ -- 1. Configuration & Constants -- ============================================================================ -local APP_VERSION_TEXT = "v1.0.35" +local APP_VERSION_TEXT = "v1.0.36" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group", @@ -2524,7 +2524,7 @@ function Main.loop() reason = reason }) - if etaSeconds >= 0 and etaSeconds <= 45 then + if etaSeconds >= 0 and etaSeconds < 30 then if not State.announcedApproaching[announceKey] then State.announcedApproaching[announceKey] = now Utils.log("INFO", string.format("Train Approaching: %s (ETA: %ds, Delay: %dm)", trainName, etaSeconds, delayMinutes)) @@ -2609,8 +2609,8 @@ function Main.loop() reason = nil }) - -- 触发逻辑:当 ETA 已经明确 <= 45秒(包括30秒、15秒、现在等),且之前没有播报过 - if etaSeconds >= 0 and etaSeconds <= 45 then + -- 触发逻辑:当 ETA 已经明确小于30秒(包括15秒、现在等),且之前没有播报过 + if etaSeconds >= 0 and etaSeconds < 30 then if not State.announcedApproaching[announceKey] then State.announcedApproaching[announceKey] = now Utils.log("INFO", string.format("Train Approaching: %s (ETA: %ds, Delay: %dm)", tName, etaSeconds, delay))