音频根据线路播放

This commit is contained in:
joylink_zhaoerwei 2024-11-08 15:57:53 +08:00
parent a57d89a7f3
commit 4adeedb4d5
27 changed files with 78 additions and 30 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
public/alarmMusic/4/red.mp3 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -12,17 +12,33 @@ import { AlarmInfo, useLineNetStore } from 'src/stores/line-net-store';
import { DialogChainObject, useQuasar } from 'quasar';
import alarmInfoDialog from 'src/components/alarm/alarmInfoDialog.vue';
import { showAlertTypeData } from './alarmInfoEnum';
import allLineBlue from '/alarmMusic/all-line-blue.mp3';
import atpcut from '/alarmMusic/atp-cut.mp3';
import blue from '/alarmMusic/blue.mp3';
import cannotClose from '/alarmMusic/cannot-close.mp3';
import cannotOpen from '/alarmMusic/cannot-open.mp3';
import orangeMost from '/alarmMusic/orange-most.mp3';
import orange from '/alarmMusic/orange.mp3';
import redMost from '/alarmMusic/red-most.mp3';
import red from '/alarmMusic/red.mp3';
import switchLostMost from '/alarmMusic/switch-lost-most.mp3';
import switchLost from '/alarmMusic/switch-lost.mp3';
import allLineBlue3 from '/alarmMusic/3/all-line-blue.mp3';
import atpcut3 from '/alarmMusic/3/atp-cut.mp3';
import blue3 from '/alarmMusic/3/blue.mp3';
import cannotClose3 from '/alarmMusic/3/cannot-close.mp3';
import cannotOpen3 from '/alarmMusic/3/cannot-open.mp3';
import orangeMost3 from '/alarmMusic/3/orange-most.mp3';
import orange3 from '/alarmMusic/3/orange.mp3';
import redMost3 from '/alarmMusic/3/red-most.mp3';
import red3 from '/alarmMusic/3/red.mp3';
import switchLostMost3 from '/alarmMusic/3/switch-lost-most.mp3';
import switchLost3 from '/alarmMusic/3/switch-lost.mp3';
import switchJammed3 from '/alarmMusic/3/switch_jammed.mp3';
import platformEmergStop3 from '/alarmMusic/3/platform_emerg_stop.mp3';
//4线
import allLineBlue4 from '/alarmMusic/4/all-line-blue.mp3';
import atpcut4 from '/alarmMusic/4/atp-cut.mp3';
import blue4 from '/alarmMusic/4/blue.mp3';
import cannotClose4 from '/alarmMusic/4/cannot-close.mp3';
import cannotOpen4 from '/alarmMusic/4/cannot-open.mp3';
import orangeMost4 from '/alarmMusic/4/orange-most.mp3';
import orange4 from '/alarmMusic/4/orange.mp3';
import redMost4 from '/alarmMusic/4/red-most.mp3';
import red4 from '/alarmMusic/4/red.mp3';
import switchLostMost4 from '/alarmMusic/4/switch-lost-most.mp3';
import switchLost4 from '/alarmMusic/4/switch-lost.mp3';
import switchJammed4 from '/alarmMusic/4/switch_jammed.mp3';
import platformEmergStop4 from '/alarmMusic/4/platform_emerg_stop.mp3';
import buzzer from '/alarmMusic/buzzer.mp3';
const lineNetStore = useLineNetStore();
@ -39,8 +55,8 @@ watch(
const hasShow = countHasShowFiveDialog();
if (!hasShow) {
const alarmType = val[0].alert_type;
alarm(alarmType, val[0].id);
playAlarmMusic(alarmType);
alarm(alarmType, val[0].id, +val[0].line_id);
playAlarmMusic(alarmType, +val[0].line_id);
} else {
waitShowDialog.push(toRaw(lineNetStore.alarmInfo[0]));
}
@ -58,7 +74,7 @@ watch(
}
);
function playAlarmMusic(type: number) {
function playAlarmMusic(type: number, lineId: number) {
for (let i = 0; i < dialogInstance.length; i++) {
if (dialogInstance[i].show == false) {
dialogInstance.splice(i, 1);
@ -67,19 +83,43 @@ function playAlarmMusic(type: number) {
}
if (lineNetStore.playAble && audio.value.paused) {
const alarmType = (showAlertTypeData as never)[type + ''];
const mapAlarmMusic = new Map([
['蓝显', blue],
['全线蓝显', allLineBlue],
['整侧站台门无法打开', cannotOpen],
['整侧站台门无法关闭', cannotClose],
['道岔失表', switchLost],
['道岔大面积失表', switchLostMost],
['计轴红光带', red],
['计轴大面积红光带', redMost],
['计轴橙光带', orange],
['计轴大面积橙光带', orangeMost],
['列车信号故障', atpcut],
]);
let mapAlarmMusic = new Map();
switch (lineId) {
case 3:
mapAlarmMusic = new Map([
['蓝显', blue3],
['全线蓝显', allLineBlue3],
['整侧站台门无法打开', cannotOpen3],
['整侧站台门无法关闭', cannotClose3],
['道岔失表', switchLost3],
['道岔大面积失表', switchLostMost3],
['计轴红光带', red3],
['计轴大面积红光带', redMost3],
['计轴橙光带', orange3],
['计轴大面积橙光带', orangeMost3],
['列车信号故障', atpcut3],
['应急触发', platformEmergStop3],
['道岔挤岔', switchJammed3],
]);
break;
case 4:
mapAlarmMusic = new Map([
['蓝显', blue4],
['全线蓝显', allLineBlue4],
['整侧站台门无法打开', cannotOpen4],
['整侧站台门无法关闭', cannotClose4],
['道岔失表', switchLost4],
['道岔大面积失表', switchLostMost4],
['计轴红光带', red4],
['计轴大面积红光带', redMost4],
['计轴橙光带', orange4],
['计轴大面积橙光带', orangeMost4],
['列车信号故障', atpcut4],
['应急触发', platformEmergStop4],
['道岔挤岔', switchJammed4],
]);
break;
}
const music = mapAlarmMusic.get(alarmType);
if (music !== undefined) {
audioSrc.value = music;
@ -102,7 +142,7 @@ function timingPlayAlarmMusic(dialog: DialogChainObject) {
!dialogInstance[i].hasHandle &&
dialogInstance[i].dialog == dialog
) {
playAlarmMusic(dialogInstance[i].alarmType);
playAlarmMusic(dialogInstance[i].alarmType, dialogInstance[i].lineId);
timingPlayAlarmMusic(dialog);
}
}
@ -116,6 +156,7 @@ const dialogInstance: {
timer: string | number | NodeJS.Timeout | undefined;
id: string;
hasHandle: boolean;
lineId: number;
}[] = [];
function countHasShowFiveDialog(): boolean {
@ -129,7 +170,12 @@ function countHasShowFiveDialog(): boolean {
return hasShow > 4 ? true : false;
}
function alarm(alarmType: number, id: string, waitAlarmMeaasge?: AlarmInfo) {
function alarm(
alarmType: number,
id: string,
lineId: number,
waitAlarmMeaasge?: AlarmInfo
) {
const dialogInstanceItem = $q
.dialog({
component: alarmInfoDialog,
@ -160,6 +206,7 @@ function alarm(alarmType: number, id: string, waitAlarmMeaasge?: AlarmInfo) {
timer,
hasHandle: false,
id,
lineId,
});
timingPlayAlarmMusic(dialogInstanceItem);
}
@ -169,9 +216,10 @@ function alarmWaitDialog() {
alarm(
waitShowDialog[0].alert_type,
waitShowDialog[0].id,
+waitShowDialog[0].line_id,
waitShowDialog[0]
);
playAlarmMusic(waitShowDialog[0].alert_type);
playAlarmMusic(waitShowDialog[0].alert_type, +waitShowDialog[0].line_id);
waitShowDialog.shift();
}
}