feat: departure广播新增下一站播报 + 客户端预解析station code
This commit is contained in:
+24
-6
@@ -2213,14 +2213,24 @@ function handleTrainDeparture(ws, data) {
|
|||||||
const trainId = data.trainId;
|
const trainId = data.trainId;
|
||||||
const stationName = getCorrectStationName(data.stationName);
|
const stationName = getCorrectStationName(data.stationName);
|
||||||
const stationCode = data.stationCode;
|
const stationCode = data.stationCode;
|
||||||
|
const platform = data.stationPlatform || data.platform || '1';
|
||||||
|
const cleanPlatform = String(platform).replace(/\D/g, '');
|
||||||
|
const finalPlatform = cleanPlatform || '1';
|
||||||
const beep = data.departureBeep || data.beep || 'fc1';
|
const beep = data.departureBeep || data.beep || 'fc1';
|
||||||
|
|
||||||
|
const lineCode = data.lineCode || (stationCode ? stationCode.split('-')[0] : 'UNK');
|
||||||
|
const destCode = data.destCode || getStationCodeFromName(data.destination) || 'UNK';
|
||||||
|
const nextStationRaw = data.nextStation ? String(data.nextStation).trim() : '';
|
||||||
|
const nextCodeRaw = data.nextCode ? String(data.nextCode).trim() : (nextStationRaw ? getStationCodeFromName(nextStationRaw) : '');
|
||||||
|
const hasNextStation = nextStationRaw && nextStationRaw !== '' && nextCodeRaw && nextCodeRaw !== 'UNK' && nextCodeRaw !== '';
|
||||||
|
const finalNextCode = hasNextStation ? nextCodeRaw : null;
|
||||||
|
|
||||||
const existingIndex = activeTrains.findIndex(t => t.trainId === trainId);
|
const existingIndex = activeTrains.findIndex(t => t.trainId === trainId);
|
||||||
if (existingIndex >= 0) {
|
if (existingIndex >= 0) {
|
||||||
activeTrains.splice(existingIndex, 1);
|
activeTrains.splice(existingIndex, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
log('INFO', `Train ${trainId} departing from ${stationName}. Broadcasting departure...`);
|
log('INFO', `Train ${trainId} departing from ${stationName}. Broadcasting departure... nextStation=${nextStationRaw || '(none/terminal)'} nextCode=${finalNextCode || '(none)'}`);
|
||||||
saveData();
|
saveData();
|
||||||
broadcastUpdate();
|
broadcastUpdate();
|
||||||
|
|
||||||
@@ -2232,11 +2242,19 @@ function handleTrainDeparture(ws, data) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Departure Audio Logic
|
// Departure Audio Logic
|
||||||
const seq = [
|
const seq = [beep, 'ja-doorwarn', 'ch-doorwarn'];
|
||||||
beep,
|
|
||||||
'ja-doorwarn',
|
if (finalNextCode) {
|
||||||
'ch-doorwarn'
|
seq.push(
|
||||||
];
|
'ja-fc1', `ja-${finalPlatform}`, 'ja-fc2', `ja-${destCode}`, 'ja-fc3', 'ja-nextsta', `ja-${finalNextCode}`,
|
||||||
|
'ch-fc1', `ch-${finalPlatform}`, 'ch-fc2', 'ch-fc3', `ch-${destCode}`, 'ch-nextsta', `ch-${finalNextCode}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
seq.push(
|
||||||
|
'ja-fc1', `ja-${finalPlatform}`, 'ja-fc2', `ja-${destCode}`, 'ja-fc3',
|
||||||
|
'ch-fc1', `ch-${finalPlatform}`, 'ch-fc2', 'ch-fc3', `ch-${destCode}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
enqueueHlsPush(stationName, seq);
|
enqueueHlsPush(stationName, seq);
|
||||||
|
|
||||||
|
|||||||
+17
-1
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
-- 1. Configuration & Constants
|
-- 1. Configuration & Constants
|
||||||
local APP_VERSION_TEXT = "v1.0.70"
|
local APP_VERSION_TEXT = "v1.0.71"
|
||||||
|
|
||||||
local CONFIG = {
|
local CONFIG = {
|
||||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||||
@@ -3529,6 +3529,13 @@ function Main.loop()
|
|||||||
local nextStation = Utils.getNextStation(schedule, State.stationName)
|
local nextStation = Utils.getNextStation(schedule, State.stationName)
|
||||||
local now = os.epoch("utc") / 1000
|
local now = os.epoch("utc") / 1000
|
||||||
local stationTime = Utils.getStopTime(schedule, State.stationName) or 60
|
local stationTime = Utils.getStopTime(schedule, State.stationName) or 60
|
||||||
|
local lineCode = Utils.getStationCode(State.stationCode or State.stationName)
|
||||||
|
if lineCode then
|
||||||
|
local dash = lineCode:find("-")
|
||||||
|
if dash then lineCode = lineCode:sub(1, dash - 1) end
|
||||||
|
end
|
||||||
|
local destCode = Utils.getStationCode(dest)
|
||||||
|
local nextCode = Utils.getStationCode(nextStation)
|
||||||
|
|
||||||
State.currentTrain = {
|
State.currentTrain = {
|
||||||
id = id,
|
id = id,
|
||||||
@@ -3536,6 +3543,9 @@ function Main.loop()
|
|||||||
schedule = schedule,
|
schedule = schedule,
|
||||||
dest = dest,
|
dest = dest,
|
||||||
nextStation = nextStation,
|
nextStation = nextStation,
|
||||||
|
lineCode = lineCode,
|
||||||
|
destCode = destCode,
|
||||||
|
nextCode = nextCode,
|
||||||
arrivalTime = now,
|
arrivalTime = now,
|
||||||
departureTime = now + stationTime,
|
departureTime = now + stationTime,
|
||||||
platform = Utils.getPlatformNumber(State.stationName, "1"),
|
platform = Utils.getPlatformNumber(State.stationName, "1"),
|
||||||
@@ -3549,7 +3559,10 @@ function Main.loop()
|
|||||||
stationPlatform = State.stationPlatform,
|
stationPlatform = State.stationPlatform,
|
||||||
trainId = id,
|
trainId = id,
|
||||||
destination = dest,
|
destination = dest,
|
||||||
|
destCode = destCode,
|
||||||
nextStation = nextStation,
|
nextStation = nextStation,
|
||||||
|
nextCode = nextCode,
|
||||||
|
lineCode = lineCode,
|
||||||
departureTime = State.currentTrain.departureTime,
|
departureTime = State.currentTrain.departureTime,
|
||||||
departureBeep = State.departureBeep
|
departureBeep = State.departureBeep
|
||||||
})
|
})
|
||||||
@@ -3566,7 +3579,10 @@ function Main.loop()
|
|||||||
stationPlatform = State.stationPlatform,
|
stationPlatform = State.stationPlatform,
|
||||||
trainId = State.currentTrain.id,
|
trainId = State.currentTrain.id,
|
||||||
destination = State.currentTrain.dest,
|
destination = State.currentTrain.dest,
|
||||||
|
destCode = State.currentTrain.destCode,
|
||||||
nextStation = State.currentTrain.nextStation,
|
nextStation = State.currentTrain.nextStation,
|
||||||
|
nextCode = State.currentTrain.nextCode,
|
||||||
|
lineCode = State.currentTrain.lineCode,
|
||||||
departureBeep = State.departureBeep
|
departureBeep = State.departureBeep
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user