fix: trigger approaching broadcast under 30 seconds

This commit is contained in:
2026-08-02 17:42:49 +08:00
parent b7be4cd00d
commit f922ace154
2 changed files with 23 additions and 12 deletions
+19 -8
View File
@@ -1866,8 +1866,9 @@ function handleTrainApproaching(ws, data) {
const finalPlatform = cleanPlatform || '1'; const finalPlatform = cleanPlatform || '1';
const destCode = data.destCode || getStationCodeFromName(data.destination) || 'UNK'; 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({ ws.send(JSON.stringify({
type: 'train_approaching_ack', type: 'train_approaching_ack',
@@ -1880,11 +1881,21 @@ function handleTrainApproaching(ws, data) {
// 提示音:ksts // 提示音:ksts
// 日文:ja-fc1 + ja-站台编号 + ja-fc2 + ja-终点编号 + ja-fc3 // 日文:ja-fc1 + ja-站台编号 + ja-fc2 + ja-终点编号 + ja-fc3
// 中文:ch-fc1 + ch-fc2 + ch-fc3 + ch-终点编号 + ch-fc4 // 中文:ch-fc1 + ch-fc2 + ch-fc3 + ch-终点编号 + ch-fc4
const seq = [ const seq = ['ksts'];
'ksts',
'ja-fc1', `ja-${finalPlatform}`, 'ja-fc2', `ja-${destCode}`, 'ja-fc3', // 拼接日文
'ch-fc1', 'ch-fc2', 'ch-fc3', `ch-${destCode}`, 'ch-fc4' 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); enqueueHlsPush(stationName, seq);
@@ -1896,8 +1907,8 @@ function handleTrainApproaching(ws, data) {
sourcePath: built.sourcePath, sourcePath: built.sourcePath,
streamUrl: built.streamUrl, streamUrl: built.streamUrl,
durationSec: built.durationSec, durationSec: built.durationSec,
priority: 1, priority: 0,
interruptMode: 'ifLower', interruptMode: 'none',
source: 'train_approaching', source: 'train_approaching',
audioId, audioId,
consoleStreamStart: { type: 'stream_start', station: stationName, seq, streamName: getStationStreamName(stationName), hlsUrl: getStationHlsUrl(getStationStreamName(stationName)) }, consoleStreamStart: { type: 'stream_start', station: stationName, seq, streamName: getStationStreamName(stationName), hlsUrl: getStationHlsUrl(getStationStreamName(stationName)) },
+4 -4
View File
@@ -2,7 +2,7 @@
-- ============================================================================ -- ============================================================================
-- 1. Configuration & Constants -- 1. Configuration & Constants
-- ============================================================================ -- ============================================================================
local APP_VERSION_TEXT = "v1.0.35" local APP_VERSION_TEXT = "v1.0.36"
local CONFIG = { local CONFIG = {
CLOUD_URL = "ws://stabadmin.fse-media.group", CLOUD_URL = "ws://stabadmin.fse-media.group",
@@ -2524,7 +2524,7 @@ function Main.loop()
reason = reason reason = reason
}) })
if etaSeconds >= 0 and etaSeconds <= 45 then if etaSeconds >= 0 and etaSeconds < 30 then
if not State.announcedApproaching[announceKey] then if not State.announcedApproaching[announceKey] then
State.announcedApproaching[announceKey] = now State.announcedApproaching[announceKey] = now
Utils.log("INFO", string.format("Train Approaching: %s (ETA: %ds, Delay: %dm)", trainName, etaSeconds, delayMinutes)) Utils.log("INFO", string.format("Train Approaching: %s (ETA: %ds, Delay: %dm)", trainName, etaSeconds, delayMinutes))
@@ -2609,8 +2609,8 @@ function Main.loop()
reason = nil reason = nil
}) })
-- 触发逻辑:当 ETA 已经明确 <= 45秒(包括30秒、15秒、现在等),且之前没有播报过 -- 触发逻辑:当 ETA 已经明确小于30秒(包括15秒、现在等),且之前没有播报过
if etaSeconds >= 0 and etaSeconds <= 45 then if etaSeconds >= 0 and etaSeconds < 30 then
if not State.announcedApproaching[announceKey] then if not State.announcedApproaching[announceKey] then
State.announcedApproaching[announceKey] = now State.announcedApproaching[announceKey] = now
Utils.log("INFO", string.format("Train Approaching: %s (ETA: %ds, Delay: %dm)", tName, etaSeconds, delay)) Utils.log("INFO", string.format("Train Approaching: %s (ETA: %ds, Delay: %dm)", tName, etaSeconds, delay))