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 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)) },
+4 -4
View File
@@ -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))