功能(站点广播): 实现延误与停运列车的双语广播功能
添加所有中日文广播所需的音频资源文件 将应用版本更新至v1.0.37 修复列车状态原因映射逻辑,补充广播所需的缺失字段 实现根据延误、停运状态生成对应双语广播序列的逻辑 更新测试脚本以适配区块阅读器并正确解析CRN的NBT数据 添加示例NBT转储文件作为参考
This commit is contained in:
+27
-15
@@ -1865,8 +1865,11 @@ function handleTrainApproaching(ws, data) {
|
||||
const cleanPlatform = String(platform).replace(/\D/g, ''); // 提取数字部分
|
||||
const finalPlatform = cleanPlatform || '1';
|
||||
|
||||
const lineCode = data.lineCode || (stationCode ? stationCode.split('-')[0] : 'UNK');
|
||||
const destCode = data.destCode || getStationCodeFromName(data.destination) || 'UNK';
|
||||
const delay = Number(data.delay) || 0; // 获取延误信息(分钟)
|
||||
const delay = Math.max(0, Number(data.delay) || 0); // 获取延误信息(分钟)
|
||||
const cancelled = Boolean(data.cancelled);
|
||||
const rawReason = String(data.reason || '').trim();
|
||||
|
||||
log('INFO', `Train ${trainId} approaching ${stationName} (Delay: ${delay} min). Broadcasting pre-arrival...`);
|
||||
|
||||
@@ -1877,24 +1880,33 @@ function handleTrainApproaching(ws, data) {
|
||||
trainId
|
||||
}));
|
||||
|
||||
// Pre-arrival Audio Logic
|
||||
// 提示音:ksts
|
||||
// 日文:ja-fc1 + ja-站台编号 + ja-fc2 + ja-终点编号 + ja-fc3
|
||||
// 中文:ch-fc1 + ch-fc2 + ch-fc3 + ch-终点编号 + 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');
|
||||
|
||||
const normalizeReason = (reason, lang) => {
|
||||
let r = String(reason || '').trim();
|
||||
if (!r || r === 'delay') r = 'default_delay';
|
||||
if (lang === 'ch' && r === 'train') r = 'delaytrain';
|
||||
return r;
|
||||
};
|
||||
|
||||
if (cancelled) {
|
||||
seq.push(
|
||||
'ksts',
|
||||
'ja-cancel1', `ja-${lineCode}`, 'ja-cancel2',
|
||||
'ch-cancel1', `ch-${lineCode}`, 'ch-cancel2'
|
||||
);
|
||||
} else if (delay > 0) {
|
||||
const d = Math.max(1, Math.round(delay));
|
||||
const jaReason = normalizeReason(rawReason, 'ja');
|
||||
const chReason = normalizeReason(rawReason, 'ch');
|
||||
seq.push(
|
||||
'ksts',
|
||||
'ja-delay1', `ja-${lineCode}`, `ja-${jaReason}`, 'ja-delay2', `ja-${d}min`, 'ja-delay3',
|
||||
'ch-delay1', `ch-${lineCode}`, 'ch-delay2', `ch-${chReason}`, 'ch-delay3', `ch-${d}`, 'ch-min', 'ch-delay4'
|
||||
);
|
||||
}
|
||||
|
||||
enqueueHlsPush(stationName, seq);
|
||||
|
||||
Reference in New Issue
Block a user