手动设置故障

This commit is contained in:
joylink_zhaoerwei 2023-07-21 16:45:17 +08:00
parent 773010b73e
commit 2f2bc0fe31
8 changed files with 188 additions and 87 deletions

11
src/api/AlertMock.ts Normal file
View File

@ -0,0 +1,11 @@
import { api } from 'src/boot/axios';
const alertUriBase = '/api/alert/mock';
export function mockAlertSet(data: { lineId: number; alertType: string }) {
return api.post(`${alertUriBase}/set`, data);
}
export function mockAlertClear() {
return api.post(`${alertUriBase}/clear`);
}

View File

@ -51,7 +51,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import DraggableDialog from './common/DraggableDialog.vue'; import DraggableDialog from '../common/DraggableDialog.vue';
import { useLineNetStore } from 'src/stores/line-net-store'; import { useLineNetStore } from 'src/stores/line-net-store';
import { onMounted, ref, watch } from 'vue'; import { onMounted, ref, watch } from 'vue';
import { queryAlarmInfoById } from 'src/api/DecisionInfo'; import { queryAlarmInfoById } from 'src/api/DecisionInfo';
@ -65,7 +65,6 @@ watch(
() => lineNetStore.alarmInfo, () => lineNetStore.alarmInfo,
(val) => { (val) => {
if (val.length) { if (val.length) {
bgColor.value = 'orange';
search(); search();
updata(); updata();
} }
@ -85,6 +84,13 @@ const mapAlarmMessage = new Map([
['PLATFORM_DOOR_CANNOT_CLOSE', '整侧站台门无法关闭'], ['PLATFORM_DOOR_CANNOT_CLOSE', '整侧站台门无法关闭'],
]); ]);
const mapColor = new Map([
['I', 'red'],
['II', 'yellow'],
['III', 'orange'],
['IV', 'blue'],
]);
const $q = useQuasar(); const $q = useQuasar();
const alarmInfo = ref({ const alarmInfo = ref({
id: '', id: '',
@ -104,13 +110,16 @@ onMounted(() => {
}); });
function updata() { function updata() {
bgColor.value = mapColor.get(lineNetStore.alarmInfo[0].level) as string;
alarmInfo.value.time = lineNetStore.alarmInfo[0].alert_time alarmInfo.value.time = lineNetStore.alarmInfo[0].alert_time
.substring(0, 19) .substring(0, 19)
.replace('T', ' '); .replace('T', ' ');
alarmInfo.value.level = lineNetStore.alarmInfo[0].level; alarmInfo.value.level = mapAlarmMessage.get(
alarmInfo.value.deviceInfo = lineNetStore.alarmInfo[0].device_info; lineNetStore.alarmInfo[0].level
) as string;
//alarmInfo.value.deviceInfo = lineNetStore.alarmInfo[0].device_info;
alarmInfo.value.info = lineNetStore.alarmInfo[0].info; alarmInfo.value.info = lineNetStore.alarmInfo[0].info;
alarmInfo.value.reason = lineNetStore.alarmInfo[0].reason; //alarmInfo.value.reason = lineNetStore.alarmInfo[0].reason;
} }
async function search() { async function search() {

View File

@ -0,0 +1,51 @@
<template>
<div>
<audio ref="audio">
<source src="../../assets/buzzer.mp3" type="audio/mpeg" />
</audio>
</div>
</template>
<script setup lang="ts">
import { watch, onUnmounted, ref } from 'vue';
import { useLineNetStore } from 'src/stores/line-net-store';
import { useQuasar } from 'quasar';
import alarmInfoDialog from 'src/components/alarm/alarmInfoDialog.vue';
const lineNetStore = useLineNetStore();
const audio = ref();
const $q = useQuasar();
const dialogInstance = ref();
watch(
() => lineNetStore.alarmInfo,
(val) => {
if (val.length && audio.value.paused) {
playAlarmMusic();
}
if (val.length && !lineNetStore.alarmDialog) {
alarm();
}
},
{ deep: true }
);
function playAlarmMusic() {
audio.value.play();
}
function alarm() {
lineNetStore.alarmDialog = true;
dialogInstance.value = $q
.dialog({ component: alarmInfoDialog })
.onCancel(() => {
lineNetStore.alarmDialog = false;
});
}
onUnmounted(() => {
if (dialogInstance.value && lineNetStore.alarmDialog) {
dialogInstance.value.hide();
}
});
</script>

View File

@ -61,6 +61,8 @@ import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu'; import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
import { LogicSectionTemplate } from 'src/graphics/logicSection/LogicSection'; import { LogicSectionTemplate } from 'src/graphics/logicSection/LogicSection';
import { LogicSectionData } from './graphics/LogicSectionInteraction'; import { LogicSectionData } from './graphics/LogicSectionInteraction';
import { alert } from 'src/protos/alertInfo';
import { useLineNetStore } from 'src/stores/line-net-store';
// const QuickJumpMenu = new ContextMenu({ // const QuickJumpMenu = new ContextMenu({
// name: '快捷跳转', // name: '快捷跳转',
@ -244,6 +246,14 @@ export async function loadLineDatas(app: GraphicApp) {
return states; return states;
}, },
}); });
const lineNetStore = useLineNetStore();
msgBroker.subscribe({
destination: '/queue/xian/ncc/alert',
messageHandle: (message: Uint8Array) => {
const storage = alert.NccAlertInfoMessage.deserialize(message);
lineNetStore.setAlarmInfo(storage.messages as []);
},
});
} else { } else {
app.loadGraphic([]); app.loadGraphic([]);
} }

View File

@ -132,13 +132,13 @@ export async function loadLineNetDatas(app: GraphicApp) {
return states; return states;
}, },
}); });
/* msgBroker.subscribe({ msgBroker.subscribe({
destination: '/queue/xian/ncc/alert', destination: '/queue/xian/ncc/alert',
messageHandle: (message: Uint8Array) => { messageHandle: (message: Uint8Array) => {
const storage = alert.NccAlertInfoMessage.deserialize(message); const storage = alert.NccAlertInfoMessage.deserialize(message);
lineNetStore.setAlarmInfo(storage.messages as []); lineNetStore.setAlarmInfo(storage.messages as []);
}, },
}); */ });
} else { } else {
app.loadGraphic([]); app.loadGraphic([]);
} }

View File

@ -3,6 +3,18 @@
<q-header reveal class="bg-primary text-white"> <q-header reveal class="bg-primary text-white">
<q-toolbar> <q-toolbar>
<q-toolbar-title> {{ mapName }} </q-toolbar-title> <q-toolbar-title> {{ mapName }} </q-toolbar-title>
<q-btn color="info" label="故障设置" class="q-mr-sm">
<q-menu>
<q-list style="min-width: 100px">
<q-item clickable v-close-popup @click="alertSetShow = true">
<q-item-section>设置模拟故障</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="clearMockAlert">
<q-item-section>取消模拟故障</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
<q-btn color="info" label="返回" @click="backConfirm" /> <q-btn color="info" label="返回" @click="backConfirm" />
</q-toolbar> </q-toolbar>
<q-resize-observer @resize="onHeaderResize" /> <q-resize-observer @resize="onHeaderResize" />
@ -12,6 +24,31 @@
<div id="line-app-container"></div> <div id="line-app-container"></div>
</q-page-container> </q-page-container>
</q-layout> </q-layout>
<q-dialog
v-model="alertSetShow"
persistent
transition-show="scale"
transition-hide="scale"
>
<q-card style="width: 300px" class="q-pa-md">
<q-form ref="myForm" @submit="alarmMockSet" class="q-gutter-md">
<div class="text-h6">设置模拟故障</div>
<q-select
outlined
label="故障类型"
v-model="alertType"
:options="optionsAlertType"
:rules="[(val) => val.length > 0 || '请选择故障类型!']"
/>
<q-card-actions align="right">
<q-btn color="primary" label="创建" type="submit" />
<q-btn label="取消" v-close-popup />
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
<commonAlarm />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -20,6 +57,9 @@ import { useLineStore } from 'src/stores/line-store';
import { useLineNetStore } from 'src/stores/line-net-store'; import { useLineNetStore } from 'src/stores/line-net-store';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { loadLineDatas, getLineApp } from 'src/drawApp/lineApp'; import { loadLineDatas, getLineApp } from 'src/drawApp/lineApp';
import { mockAlertSet, mockAlertClear } from 'src/api/AlertMock';
import commonAlarm from 'src/components/alarm/commonAlarm.vue';
import { useQuasar } from 'quasar';
const canvasWidth = ref(0); const canvasWidth = ref(0);
const canvasHeight = ref(0); const canvasHeight = ref(0);
@ -55,6 +95,48 @@ function onHeaderResize(size: { height: number; width: number }) {
function backConfirm() { function backConfirm() {
router.replace('/monitor'); router.replace('/monitor');
} }
//
const $q = useQuasar();
const alertSetShow = ref(false);
const alertType = ref('');
const optionsAlertType = [
'列车延误',
'蓝显',
'站台门无关闭且锁紧信号',
'整侧站台门无法打开',
'整侧站台门无法关闭',
];
enum saveAlertTypeData {
列车延误 = 'TRAIN_DELAY',
蓝显 = 'BLUE_DISPLAY',
站台门无关闭且锁紧信号 = 'PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL',
整侧站台门无法打开 = 'PLATFORM_DOOR_CANNOT_OPEN',
整侧站台门无法关闭 = 'PLATFORM_DOOR_CANNOT_CLOSE',
}
async function alarmMockSet() {
try {
const type = (saveAlertTypeData as never)[alertType.value];
const lineId = +route.params.lineId as number;
await mockAlertSet({ lineId: lineId, alertType: type });
alertSetShow.value = false;
} catch (err) {
$q.notify({
type: 'negative',
message: '无法设置模拟故障',
});
}
}
async function clearMockAlert() {
try {
await mockAlertClear();
} catch (err) {
$q.notify({
type: 'negative',
message: '无法取消模拟故障',
});
}
}
onMounted(() => { onMounted(() => {
const dom = document.getElementById('line-app-container'); const dom = document.getElementById('line-app-container');

View File

@ -2,21 +2,16 @@
<q-page class="row items-center justify-evenly"> <q-page class="row items-center justify-evenly">
<div id="line-app-container"></div> <div id="line-app-container"></div>
</q-page> </q-page>
<div> <commonAlarm />
<audio ref="audio">
<source src="src/assets/buzzer.mp3" type="audio/mpeg" />
</audio>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, watch, onUnmounted, ref } from 'vue'; import { onMounted, watch, onUnmounted } from 'vue';
import { useLineNetStore } from 'src/stores/line-net-store'; import { useLineNetStore } from 'src/stores/line-net-store';
import { loadLineNetDatas, getLineNetApp } from 'src/drawApp/lineNetApp'; import { loadLineNetDatas, getLineNetApp } from 'src/drawApp/lineNetApp';
import { RunLine } from 'src/graphics/runLine/RunLine'; import { RunLine } from 'src/graphics/runLine/RunLine';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useQuasar } from 'quasar'; import commonAlarm from 'src/components/alarm/commonAlarm.vue';
import errrorMessageBox from 'src/components/errrorMessageBox.vue';
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -64,37 +59,6 @@ function onResize() {
} }
} }
//
const audio = ref();
const $q = useQuasar();
const dialogInstance = ref();
watch(
() => lineNetStore.alarmInfo,
(val) => {
if (val.length && audio.value.paused) {
playAlarmMusic();
}
if (val.length && !lineNetStore.alarmDialog) {
alarm();
}
},
{ deep: true }
);
function playAlarmMusic() {
audio.value.play();
}
function alarm() {
lineNetStore.alarmDialog = true;
dialogInstance.value = $q
.dialog({ component: errrorMessageBox })
.onCancel(() => {
lineNetStore.alarmDialog = false;
});
}
onMounted(() => { onMounted(() => {
const dom = document.getElementById('line-app-container'); const dom = document.getElementById('line-app-container');
if (dom) { if (dom) {
@ -106,8 +70,5 @@ onMounted(() => {
onUnmounted(() => { onUnmounted(() => {
lineNetStore.destroy(); lineNetStore.destroy();
if (dialogInstance.value) {
dialogInstance.value.hide();
}
}); });
</script> </script>

View File

@ -81,8 +81,7 @@ export namespace alert {
alert_time?: string; alert_time?: string;
info?: string; info?: string;
alert_tip_id?: number; alert_tip_id?: number;
device_info?: string; mock?: boolean;
reason?: string;
}) { }) {
super(); super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -102,11 +101,8 @@ export namespace alert {
if ("alert_tip_id" in data && data.alert_tip_id != undefined) { if ("alert_tip_id" in data && data.alert_tip_id != undefined) {
this.alert_tip_id = data.alert_tip_id; this.alert_tip_id = data.alert_tip_id;
} }
if ("device_info" in data && data.device_info != undefined) { if ("mock" in data && data.mock != undefined) {
this.device_info = data.device_info; this.mock = data.mock;
}
if ("reason" in data && data.reason != undefined) {
this.reason = data.reason;
} }
} }
} }
@ -140,26 +136,19 @@ export namespace alert {
set alert_tip_id(value: number) { set alert_tip_id(value: number) {
pb_1.Message.setField(this, 5, value); pb_1.Message.setField(this, 5, value);
} }
get device_info() { get mock() {
return pb_1.Message.getFieldWithDefault(this, 6, "") as string; return pb_1.Message.getFieldWithDefault(this, 6, false) as boolean;
} }
set device_info(value: string) { set mock(value: boolean) {
pb_1.Message.setField(this, 6, value); pb_1.Message.setField(this, 6, value);
} }
get reason() {
return pb_1.Message.getFieldWithDefault(this, 7, "") as string;
}
set reason(value: string) {
pb_1.Message.setField(this, 7, value);
}
static fromObject(data: { static fromObject(data: {
id?: string; id?: string;
level?: string; level?: string;
alert_time?: string; alert_time?: string;
info?: string; info?: string;
alert_tip_id?: number; alert_tip_id?: number;
device_info?: string; mock?: boolean;
reason?: string;
}): Message { }): Message {
const message = new Message({}); const message = new Message({});
if (data.id != null) { if (data.id != null) {
@ -177,11 +166,8 @@ export namespace alert {
if (data.alert_tip_id != null) { if (data.alert_tip_id != null) {
message.alert_tip_id = data.alert_tip_id; message.alert_tip_id = data.alert_tip_id;
} }
if (data.device_info != null) { if (data.mock != null) {
message.device_info = data.device_info; message.mock = data.mock;
}
if (data.reason != null) {
message.reason = data.reason;
} }
return message; return message;
} }
@ -192,8 +178,7 @@ export namespace alert {
alert_time?: string; alert_time?: string;
info?: string; info?: string;
alert_tip_id?: number; alert_tip_id?: number;
device_info?: string; mock?: boolean;
reason?: string;
} = {}; } = {};
if (this.id != null) { if (this.id != null) {
data.id = this.id; data.id = this.id;
@ -210,11 +195,8 @@ export namespace alert {
if (this.alert_tip_id != null) { if (this.alert_tip_id != null) {
data.alert_tip_id = this.alert_tip_id; data.alert_tip_id = this.alert_tip_id;
} }
if (this.device_info != null) { if (this.mock != null) {
data.device_info = this.device_info; data.mock = this.mock;
}
if (this.reason != null) {
data.reason = this.reason;
} }
return data; return data;
} }
@ -232,10 +214,8 @@ export namespace alert {
writer.writeString(4, this.info); writer.writeString(4, this.info);
if (this.alert_tip_id != 0) if (this.alert_tip_id != 0)
writer.writeInt32(5, this.alert_tip_id); writer.writeInt32(5, this.alert_tip_id);
if (this.device_info.length) if (this.mock != false)
writer.writeString(6, this.device_info); writer.writeBool(6, this.mock);
if (this.reason.length)
writer.writeString(7, this.reason);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -261,10 +241,7 @@ export namespace alert {
message.alert_tip_id = reader.readInt32(); message.alert_tip_id = reader.readInt32();
break; break;
case 6: case 6:
message.device_info = reader.readString(); message.mock = reader.readBool();
break;
case 7:
message.reason = reader.readString();
break; break;
default: reader.skipField(); default: reader.skipField();
} }