手动设置故障

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>
<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 { onMounted, ref, watch } from 'vue';
import { queryAlarmInfoById } from 'src/api/DecisionInfo';
@ -65,7 +65,6 @@ watch(
() => lineNetStore.alarmInfo,
(val) => {
if (val.length) {
bgColor.value = 'orange';
search();
updata();
}
@ -85,6 +84,13 @@ const mapAlarmMessage = new Map([
['PLATFORM_DOOR_CANNOT_CLOSE', '整侧站台门无法关闭'],
]);
const mapColor = new Map([
['I', 'red'],
['II', 'yellow'],
['III', 'orange'],
['IV', 'blue'],
]);
const $q = useQuasar();
const alarmInfo = ref({
id: '',
@ -104,13 +110,16 @@ onMounted(() => {
});
function updata() {
bgColor.value = mapColor.get(lineNetStore.alarmInfo[0].level) as string;
alarmInfo.value.time = lineNetStore.alarmInfo[0].alert_time
.substring(0, 19)
.replace('T', ' ');
alarmInfo.value.level = lineNetStore.alarmInfo[0].level;
alarmInfo.value.deviceInfo = lineNetStore.alarmInfo[0].device_info;
alarmInfo.value.level = mapAlarmMessage.get(
lineNetStore.alarmInfo[0].level
) as string;
//alarmInfo.value.deviceInfo = lineNetStore.alarmInfo[0].device_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() {

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 { LogicSectionTemplate } from 'src/graphics/logicSection/LogicSection';
import { LogicSectionData } from './graphics/LogicSectionInteraction';
import { alert } from 'src/protos/alertInfo';
import { useLineNetStore } from 'src/stores/line-net-store';
// const QuickJumpMenu = new ContextMenu({
// name: '快捷跳转',
@ -244,6 +246,14 @@ export async function loadLineDatas(app: GraphicApp) {
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 {
app.loadGraphic([]);
}

View File

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

View File

@ -3,6 +3,18 @@
<q-header reveal class="bg-primary text-white">
<q-toolbar>
<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-toolbar>
<q-resize-observer @resize="onHeaderResize" />
@ -12,6 +24,31 @@
<div id="line-app-container"></div>
</q-page-container>
</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>
<script setup lang="ts">
@ -20,6 +57,9 @@ import { useLineStore } from 'src/stores/line-store';
import { useLineNetStore } from 'src/stores/line-net-store';
import { useRoute, useRouter } from 'vue-router';
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 canvasHeight = ref(0);
@ -55,6 +95,48 @@ function onHeaderResize(size: { height: number; width: number }) {
function backConfirm() {
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(() => {
const dom = document.getElementById('line-app-container');

View File

@ -2,21 +2,16 @@
<q-page class="row items-center justify-evenly">
<div id="line-app-container"></div>
</q-page>
<div>
<audio ref="audio">
<source src="src/assets/buzzer.mp3" type="audio/mpeg" />
</audio>
</div>
<commonAlarm />
</template>
<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 { loadLineNetDatas, getLineNetApp } from 'src/drawApp/lineNetApp';
import { RunLine } from 'src/graphics/runLine/RunLine';
import { useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import errrorMessageBox from 'src/components/errrorMessageBox.vue';
import commonAlarm from 'src/components/alarm/commonAlarm.vue';
const props = withDefaults(
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(() => {
const dom = document.getElementById('line-app-container');
if (dom) {
@ -106,8 +70,5 @@ onMounted(() => {
onUnmounted(() => {
lineNetStore.destroy();
if (dialogInstance.value) {
dialogInstance.value.hide();
}
});
</script>

View File

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