From eee398eaa1e012867797c5a6e9c8b0e83dd1854e Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Tue, 19 Mar 2024 10:22:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BD=A6=E8=BF=9E=E6=8E=A5=E6=93=8D?= =?UTF-8?q?=E4=BD=9C&=E5=88=97=E8=BD=A6=E8=BF=9E=E6=8E=A5=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rts-sim-testing-message | 2 +- src/api/Simulation.ts | 13 ++ .../draw-app/dialogs/SetTrainLink.vue | 97 ++++++++++++ src/components/line-app/infos/TrainInfo.vue | 112 +++++++++++-- src/drawApp/graphics/TrainInteraction.ts | 32 +++- src/graphics/train/Train.ts | 5 + src/protos/device_state.ts | 149 ++++++++++++++++++ 7 files changed, 399 insertions(+), 11 deletions(-) create mode 100644 src/components/draw-app/dialogs/SetTrainLink.vue diff --git a/rts-sim-testing-message b/rts-sim-testing-message index 225f92b..6dff822 160000 --- a/rts-sim-testing-message +++ b/rts-sim-testing-message @@ -1 +1 @@ -Subproject commit 225f92b91cd0ff0371b9fd785f91ddf05903ea8a +Subproject commit 6dff8221d5e43e87727328fcd3260559ff13a2a3 diff --git a/src/api/Simulation.ts b/src/api/Simulation.ts index 4d7ced4..3bcc8d5 100644 --- a/src/api/Simulation.ts +++ b/src/api/Simulation.ts @@ -417,3 +417,16 @@ export async function sendTransponderTelegram(data: { }) { return await api.put(`${UriBase}/balise/telegram/send`, data); } + +/** 获取列车可以连接平台列表 */ +export async function getCanLinkPlatForm(id: string) { + return await api.get(`${UriBase}/train/conn/type/${id}`); +} +/** 修改列车连接 */ +export async function updateTrainConn(data: { + id: string; + simulationId: string; + connType: number; +}) { + return await api.post(`${UriBase}/train/conn`, data); +} diff --git a/src/components/draw-app/dialogs/SetTrainLink.vue b/src/components/draw-app/dialogs/SetTrainLink.vue new file mode 100644 index 0000000..5ec2853 --- /dev/null +++ b/src/components/draw-app/dialogs/SetTrainLink.vue @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/line-app/infos/TrainInfo.vue b/src/components/line-app/infos/TrainInfo.vue index 90b93cb..c652ee9 100644 --- a/src/components/line-app/infos/TrainInfo.vue +++ b/src/components/line-app/infos/TrainInfo.vue @@ -3,27 +3,68 @@ 列车信息 - --> + + + + + {{ item.label }} + + + + + - - {{ item.label }} + {{ item.label }} - {{ - item.formatFn - ? item.formatFn(trainInfo[item.key]) - : trainInfo[item.key] - }} + {{ + item.formatFn + ? item.formatFn(trainInfo[item.key]) + : trainInfo[item.key] + }} @@ -147,6 +188,8 @@ import { Turnout } from 'src/graphics/turnout/Turnout'; import { Section } from 'src/graphics/section/Section'; import SetTrainParam from 'src/components/draw-app/dialogs/SetTrainParam.vue'; import { Dialog } from 'quasar'; +import { state } from 'src/protos/device_state'; +import SetTrainLink from 'src/components/draw-app/dialogs/SetTrainLink.vue'; interface KeyType { label: string; @@ -158,6 +201,8 @@ const lineStore = useLineStore(); const trainInfo = ref(); const list: KeyType[] = [ { label: '列车索引', key: 'id' }, + { label: '连接状态', key: 'conn', formatFn: connStateFormat }, + { label: '连接平台', key: 'connType', formatFn: connTypeFormat }, { label: '列车长度', key: 'trainLength', formatFn: trainLengthFormat }, { label: '车头所在设备', key: 'headDeviceId', formatFn: getDeviveName }, { label: '车头所在设备的偏移量', key: 'headOffset', formatFn: offsetFormat }, @@ -393,7 +438,20 @@ function haomiaoFormat(v: number) { function trainLengthFormat(v: number) { return `${v / 1000} m`; } - +function connStateFormat(v: boolean) { + return v ? '已连接' : '未连接'; +} +function connTypeFormat(v: state.TrainConnState.TrainConnType) { + if (v === state.TrainConnState.TrainConnType.NONE) { + return '无'; + } else if (v === state.TrainConnState.TrainConnType.PC_SIM) { + return 'PC仿真'; + } else if (v === state.TrainConnState.TrainConnType.VOBC) { + return '半实物'; + } else { + return '无'; + } +} function floatDecimal(v: number, x = 2) { // 小数精确位数 const n = v.toFixed(x); @@ -540,6 +598,42 @@ function open() { lineStore.setEchartsTrainId(trainInfo.value.id); } +const options = [ + { + label: '设置参数', + value: 1, + }, + { + label: '列车连接', + value: 2, + }, +]; + +function doTrainOperation(option: { label: string; value: number }) { + if (option.value == 1) { + setTrain(); + } else if (option.value == 2) { + linkTrain(); + } +} + +function linkTrain() { + if (!lineStore.selectedGraphics) return; + if (lineStore.deviceOpreratDialogInstance) return; + const train = lineStore.selectedGraphics[0] as Train; + lineStore.deviceOpreratDialogInstance = Dialog.create({ + title: '列车连接', + message: '', + component: SetTrainLink, + componentProps: { + trainId: train.code, + simulationId: lineStore.simulationId, + }, + cancel: true, + persistent: true, + }); +} + function setTrain() { if (!lineStore.selectedGraphics) return; if (lineStore.deviceOpreratDialogInstance) return; diff --git a/src/drawApp/graphics/TrainInteraction.ts b/src/drawApp/graphics/TrainInteraction.ts index f22d3de..426bc2d 100644 --- a/src/drawApp/graphics/TrainInteraction.ts +++ b/src/drawApp/graphics/TrainInteraction.ts @@ -15,6 +15,7 @@ import { useLineStore } from 'src/stores/line-store'; import { successNotify, errorNotify } from '../../utils/CommonNotify'; import { Dialog } from 'quasar'; import SetTrainParam from 'src/components/draw-app/dialogs/SetTrainParam.vue'; +import SetTrainLink from 'src/components/draw-app/dialogs/SetTrainLink.vue'; export class TrainState extends GraphicStateBase implements ITrainState { constructor(proto?: state.TrainMapState) { let states; @@ -660,6 +661,18 @@ export class TrainState extends GraphicStateBase implements ITrainState { set telegram(v: string) { this.states.btmState.telegram = v; } + get conn(): boolean { + return this.states.connState.conn; + } + set conn(v: boolean) { + this.states.connState.conn = v; + } + get connType(): state.TrainConnState.TrainConnType { + return this.states.connState.connType; + } + set connType(v: state.TrainConnState.TrainConnType) { + this.states.connState.connType = v; + } clone(): TrainState { return new TrainState(this.states.cloneMessage()); } @@ -677,6 +690,9 @@ export class TrainState extends GraphicStateBase implements ITrainState { const TrainParam: MenuItemOptions = { name: '设置参数', }; +const TrainLink: MenuItemOptions = { + name: '列车连接', +}; const removeTrainConfig: MenuItemOptions = { name: '清除列车', }; @@ -684,7 +700,7 @@ const TrainOperateMenu: ContextMenu = ContextMenu.init({ name: '列车操作菜单', groups: [ { - items: [TrainParam, removeTrainConfig], + items: [TrainParam, TrainLink, removeTrainConfig], }, ], }); @@ -738,6 +754,20 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin { persistent: true, }); }; + TrainLink.handler = () => { + if (lineStore.deviceOpreratDialogInstance) return; + lineStore.deviceOpreratDialogInstance = Dialog.create({ + title: '列车连接', + message: '', + component: SetTrainLink, + componentProps: { + trainId: train.code, + simulationId: simulationId, + }, + cancel: true, + persistent: true, + }); + }; removeTrainConfig.handler = () => { Dialog.create({ title: '确认', diff --git a/src/graphics/train/Train.ts b/src/graphics/train/Train.ts index c1261e0..d08036e 100644 --- a/src/graphics/train/Train.ts +++ b/src/graphics/train/Train.ts @@ -14,6 +14,7 @@ import { DevicePort, Section } from '../section/Section'; import { AxleCounting } from '../axleCounting/AxleCounting'; import { getKmDistance } from 'src/drawApp/lineScene'; import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { state } from 'src/protos/device_state'; export interface ITrainData extends GraphicData { get code(): string; // 车号 @@ -235,6 +236,10 @@ export interface ITrainState extends GraphicState { set messageCounter(v: number); get telegram(): string; set telegram(v: string); + get conn(): boolean; // 连接状态 + set conn(v: boolean); + get connType(): state.TrainConnState.TrainConnType; + set connType(v: state.TrainConnState.TrainConnType); } interface bodyWH { width: number; // 宽 diff --git a/src/protos/device_state.ts b/src/protos/device_state.ts index 4368287..52ef9e6 100644 --- a/src/protos/device_state.ts +++ b/src/protos/device_state.ts @@ -1015,6 +1015,103 @@ export namespace state { return StationState.deserialize(bytes); } } + export class TrainConnState extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + conn?: boolean; + connType?: TrainConnState.TrainConnType; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("conn" in data && data.conn != undefined) { + this.conn = data.conn; + } + if ("connType" in data && data.connType != undefined) { + this.connType = data.connType; + } + } + } + get conn() { + return pb_1.Message.getFieldWithDefault(this, 1, false) as boolean; + } + set conn(value: boolean) { + pb_1.Message.setField(this, 1, value); + } + get connType() { + return pb_1.Message.getFieldWithDefault(this, 2, TrainConnState.TrainConnType.NONE) as TrainConnState.TrainConnType; + } + set connType(value: TrainConnState.TrainConnType) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + conn?: boolean; + connType?: TrainConnState.TrainConnType; + }): TrainConnState { + const message = new TrainConnState({}); + if (data.conn != null) { + message.conn = data.conn; + } + if (data.connType != null) { + message.connType = data.connType; + } + return message; + } + toObject() { + const data: { + conn?: boolean; + connType?: TrainConnState.TrainConnType; + } = {}; + if (this.conn != null) { + data.conn = this.conn; + } + if (this.connType != null) { + data.connType = this.connType; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.conn != false) + writer.writeBool(1, this.conn); + if (this.connType != TrainConnState.TrainConnType.NONE) + writer.writeEnum(2, this.connType); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): TrainConnState { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TrainConnState(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.conn = reader.readBool(); + break; + case 2: + message.connType = reader.readEnum(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): TrainConnState { + return TrainConnState.deserialize(bytes); + } + } + export namespace TrainConnState { + export enum TrainConnType { + NONE = 0, + VOBC = 1, + PC_SIM = 2 + } + } export class TrainState extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -1041,6 +1138,7 @@ export namespace state { tailOffset?: number; tailDevicePort?: string; btmState?: BTMState; + connState?: TrainConnState; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -1114,6 +1212,9 @@ export namespace state { if ("btmState" in data && data.btmState != undefined) { this.btmState = data.btmState; } + if ("connState" in data && data.connState != undefined) { + this.connState = data.connState; + } } } get id() { @@ -1272,6 +1373,15 @@ export namespace state { get has_btmState() { return pb_1.Message.getField(this, 23) != null; } + get connState() { + return pb_1.Message.getWrapperField(this, TrainConnState, 24) as TrainConnState; + } + set connState(value: TrainConnState) { + pb_1.Message.setWrapperField(this, 24, value); + } + get has_connState() { + return pb_1.Message.getField(this, 24) != null; + } static fromObject(data: { id?: string; up?: boolean; @@ -1296,6 +1406,7 @@ export namespace state { tailOffset?: number; tailDevicePort?: string; btmState?: ReturnType; + connState?: ReturnType; }): TrainState { const message = new TrainState({}); if (data.id != null) { @@ -1367,6 +1478,9 @@ export namespace state { if (data.btmState != null) { message.btmState = BTMState.fromObject(data.btmState); } + if (data.connState != null) { + message.connState = TrainConnState.fromObject(data.connState); + } return message; } toObject() { @@ -1394,6 +1508,7 @@ export namespace state { tailOffset?: number; tailDevicePort?: string; btmState?: ReturnType; + connState?: ReturnType; } = {}; if (this.id != null) { data.id = this.id; @@ -1464,6 +1579,9 @@ export namespace state { if (this.btmState != null) { data.btmState = this.btmState.toObject(); } + if (this.connState != null) { + data.connState = this.connState.toObject(); + } return data; } serialize(): Uint8Array; @@ -1516,6 +1634,8 @@ export namespace state { writer.writeString(22, this.tailDevicePort); if (this.has_btmState) writer.writeMessage(23, this.btmState, () => this.btmState.serialize(writer)); + if (this.has_connState) + writer.writeMessage(24, this.connState, () => this.connState.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -1594,6 +1714,9 @@ export namespace state { case 23: reader.readMessage(message.btmState, () => message.btmState = BTMState.deserialize(reader)); break; + case 24: + reader.readMessage(message.connState, () => message.connState = TrainConnState.deserialize(reader)); + break; default: reader.skipField(); } } @@ -2893,6 +3016,7 @@ export namespace state { tailOffset?: number; tailDevicePort?: string; btmState?: BTMState; + connState?: TrainConnState; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [20], this.#one_of_decls); @@ -3104,6 +3228,9 @@ export namespace state { if ("btmState" in data && data.btmState != undefined) { this.btmState = data.btmState; } + if ("connState" in data && data.connState != undefined) { + this.connState = data.connState; + } } } get id() { @@ -3532,6 +3659,15 @@ export namespace state { get has_btmState() { return pb_1.Message.getField(this, 69) != null; } + get connState() { + return pb_1.Message.getWrapperField(this, TrainConnState, 70) as TrainConnState; + } + set connState(value: TrainConnState) { + pb_1.Message.setWrapperField(this, 70, value); + } + get has_connState() { + return pb_1.Message.getField(this, 70) != null; + } static fromObject(data: { id?: string; up?: boolean; @@ -3602,6 +3738,7 @@ export namespace state { tailOffset?: number; tailDevicePort?: string; btmState?: ReturnType; + connState?: ReturnType; }): TrainMapState { const message = new TrainMapState({}); if (data.id != null) { @@ -3811,6 +3948,9 @@ export namespace state { if (data.btmState != null) { message.btmState = BTMState.fromObject(data.btmState); } + if (data.connState != null) { + message.connState = TrainConnState.fromObject(data.connState); + } return message; } toObject() { @@ -3884,6 +4024,7 @@ export namespace state { tailOffset?: number; tailDevicePort?: string; btmState?: ReturnType; + connState?: ReturnType; } = {}; if (this.id != null) { data.id = this.id; @@ -4092,6 +4233,9 @@ export namespace state { if (this.btmState != null) { data.btmState = this.btmState.toObject(); } + if (this.connState != null) { + data.connState = this.connState.toObject(); + } return data; } serialize(): Uint8Array; @@ -4236,6 +4380,8 @@ export namespace state { writer.writeString(68, this.tailDevicePort); if (this.has_btmState) writer.writeMessage(69, this.btmState, () => this.btmState.serialize(writer)); + if (this.has_connState) + writer.writeMessage(70, this.connState, () => this.connState.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -4452,6 +4598,9 @@ export namespace state { case 69: reader.readMessage(message.btmState, () => message.btmState = BTMState.deserialize(reader)); break; + case 70: + reader.readMessage(message.connState, () => message.connState = TrainConnState.deserialize(reader)); + break; default: reader.skipField(); } }