From 10b5e4fade3ec3cbbc2901bccd43e96919847bbf Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 13 Sep 2023 13:50:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=90=8C=E6=AD=A5protos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/protos/device_state.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/protos/device_state.ts b/src/protos/device_state.ts index 9c3ee80..6f452a4 100644 --- a/src/protos/device_state.ts +++ b/src/protos/device_state.ts @@ -544,6 +544,7 @@ export namespace state { headDirection?: boolean; dynamicState?: TrainDynamicState; vobcState?: TrainVobcState; + trainKilometer?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -587,6 +588,9 @@ export namespace state { if ("vobcState" in data && data.vobcState != undefined) { this.vobcState = data.vobcState; } + if ("trainKilometer" in data && data.trainKilometer != undefined) { + this.trainKilometer = data.trainKilometer; + } } } get id() { @@ -673,6 +677,12 @@ export namespace state { get has_vobcState() { return pb_1.Message.getField(this, 13) != null; } + get trainKilometer() { + return pb_1.Message.getFieldWithDefault(this, 14, 0) as number; + } + set trainKilometer(value: number) { + pb_1.Message.setField(this, 14, value); + } static fromObject(data: { id?: string; up?: boolean; @@ -687,6 +697,7 @@ export namespace state { headDirection?: boolean; dynamicState?: ReturnType; vobcState?: ReturnType; + trainKilometer?: number; }): TrainState { const message = new TrainState({}); if (data.id != null) { @@ -728,6 +739,9 @@ export namespace state { if (data.vobcState != null) { message.vobcState = TrainVobcState.fromObject(data.vobcState); } + if (data.trainKilometer != null) { + message.trainKilometer = data.trainKilometer; + } return message; } toObject() { @@ -745,6 +759,7 @@ export namespace state { headDirection?: boolean; dynamicState?: ReturnType; vobcState?: ReturnType; + trainKilometer?: number; } = {}; if (this.id != null) { data.id = this.id; @@ -785,6 +800,9 @@ export namespace state { if (this.vobcState != null) { data.vobcState = this.vobcState.toObject(); } + if (this.trainKilometer != null) { + data.trainKilometer = this.trainKilometer; + } return data; } serialize(): Uint8Array; @@ -817,6 +835,8 @@ export namespace state { writer.writeMessage(12, this.dynamicState, () => this.dynamicState.serialize(writer)); if (this.has_vobcState) writer.writeMessage(13, this.vobcState, () => this.vobcState.serialize(writer)); + if (this.trainKilometer != 0) + writer.writeInt64(14, this.trainKilometer); if (!w) return writer.getResultBuffer(); } @@ -865,6 +885,9 @@ export namespace state { case 13: reader.readMessage(message.vobcState, () => message.vobcState = TrainVobcState.deserialize(reader)); break; + case 14: + message.trainKilometer = reader.readInt64(); + break; default: reader.skipField(); } } From 638eca3ab4918adad5732517c470c75ad0aa1cec Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 13 Sep 2023 14:46:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=97=E8=BD=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=AC=E9=87=8C=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/line-app/infos/TrainInfo.vue | 22 +++++++++++++++++++++ src/drawApp/graphics/TrainInteraction.ts | 6 ++++++ src/graphics/train/Train.ts | 2 ++ 3 files changed, 30 insertions(+) diff --git a/src/components/line-app/infos/TrainInfo.vue b/src/components/line-app/infos/TrainInfo.vue index 0392943..6177265 100644 --- a/src/components/line-app/infos/TrainInfo.vue +++ b/src/components/line-app/infos/TrainInfo.vue @@ -77,6 +77,11 @@ const list: KeyType[] = [ { label: '车头所在设备的偏移量', key: 'headOffset', formatFn: offsetFormat }, { label: '是否上行', key: 'runDirection', formatFn: upFormat }, { label: '车头方向是否上行', key: 'headDirection', formatFn: upFormat }, + { + label: '所在公里标', + key: 'trainKilometer', + formatFn: trainKilometerFormat, + }, ]; const list2: DynamicKeyType[] = [ // 动力学信息 @@ -212,6 +217,23 @@ function trainLoadFormat(v: number) { return `${n} ton`; } +function trainKilometerFormat(v: number) { + const f = floatDecimal(v, 0); + const r = f.split('').reverse(); + const x = r.slice(0, 3).reverse(); + const m = r.slice(3, 6).reverse(); + const k = r.slice(6).reverse(); + let n = ''; + if (k.length) { + n = `k${k.join('')}+${m.join('')}.${x.join('')}`; + } else if (m.length) { + n = `${m.join('')}.${x.join('')}`; + } else if (x.length) { + n = `0.${x.join('')}`; + } + return n; +} + function getDeviveName() { const headDeviceId = trainInfo.value?.headDeviceId; const devicePort = trainInfo.value?.devicePort; diff --git a/src/drawApp/graphics/TrainInteraction.ts b/src/drawApp/graphics/TrainInteraction.ts index 1441f4b..5784d6c 100644 --- a/src/drawApp/graphics/TrainInteraction.ts +++ b/src/drawApp/graphics/TrainInteraction.ts @@ -110,6 +110,12 @@ export class TrainState extends GraphicStateBase implements ITrainState { set vobcState(v: state.TrainVobcState) { this.states.vobcState = new state.TrainVobcState(v); } + get trainKilometer(): number { + return this.states.trainKilometer; + } + set trainKilometer(v: number) { + this.states.trainKilometer = v; + } clone(): TrainState { return new TrainState(this.states.cloneMessage()); } diff --git a/src/graphics/train/Train.ts b/src/graphics/train/Train.ts index 411d014..8f08fcb 100644 --- a/src/graphics/train/Train.ts +++ b/src/graphics/train/Train.ts @@ -49,6 +49,8 @@ export interface ITrainState extends GraphicState { set dynamicState(v: state.TrainDynamicState); get vobcState(): state.TrainVobcState; set vobcState(v: state.TrainVobcState); + get trainKilometer(): number; + set trainKilometer(v: number); } interface bodyWH {