添加socket订阅
This commit is contained in:
parent
c0ebe15789
commit
dba7d34f1a
@ -67,6 +67,9 @@ import {
|
||||
LogicSectionState,
|
||||
} from './graphics/LogicSectionInteraction';
|
||||
import { CanvasData, IGraphicAppConfig } from 'src/jl-graphic/app/JlGraphicApp';
|
||||
import { Notify, QNotifyUpdateOptions } from 'quasar';
|
||||
import { useLineNetStore } from 'src/stores/line-net-store';
|
||||
import { alert } from 'src/protos/alertInfo';
|
||||
|
||||
let lineApp: IGraphicApp | null = null;
|
||||
|
||||
@ -211,6 +214,43 @@ export function initLineApp(lineId: number): IGraphicApp {
|
||||
return states;
|
||||
},
|
||||
});
|
||||
lineApp.subscribe({
|
||||
destination: `/queue/line/${lineId}/train`,
|
||||
messageConverter: (message: Uint8Array) => {
|
||||
const states: GraphicState[] = [];
|
||||
const trainStorage = state.WsLineTrainMessage.deserialize(message);
|
||||
// console.log(trainStorage, '222');
|
||||
trainStorage.trainInfo.forEach((item) => {
|
||||
if (item.rtuId !== 81 && item.rtuId !== 82 && item.rtuId) {
|
||||
states.push(new TrainState(item));
|
||||
}
|
||||
});
|
||||
return states;
|
||||
},
|
||||
});
|
||||
let msgNotify: null | ((props?: QNotifyUpdateOptions | undefined) => void) =
|
||||
null;
|
||||
lineApp.on('websocket-connect-state-change', (connected) => {
|
||||
if (!connected && !msgNotify) {
|
||||
msgNotify = Notify.create({
|
||||
type: 'negative',
|
||||
timeout: 0,
|
||||
position: 'top-right',
|
||||
message: '通信链接已断开!',
|
||||
});
|
||||
} else if (msgNotify && connected) {
|
||||
msgNotify();
|
||||
msgNotify = null;
|
||||
}
|
||||
});
|
||||
const lineNetStore = useLineNetStore();
|
||||
lineApp.subscribe({
|
||||
destination: '/queue/xian/ncc/alert',
|
||||
messageHandle: (message: Uint8Array) => {
|
||||
const storage = alert.NccAlertInfoMessage.deserialize(message);
|
||||
lineNetStore.setAlarmInfo(storage.messages as []);
|
||||
},
|
||||
});
|
||||
|
||||
lineApp.reload().then(() => {
|
||||
if (!lineApp) return;
|
||||
|
Loading…
Reference in New Issue
Block a user