From f37f323cd6019c0d13b0a60e82e3eedb8aa74c7b Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Wed, 21 Aug 2024 18:25:36 +0800 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 1b855710056f0d2c342cfe5e3c5082350eaf0094 Author: joylink_zhaoerwei Date: Wed Aug 21 18:23:43 2024 +0800 驾驶台接收信息修改(待与后端测试) commit fe56bdc27da8c492cbe1cf4c84f34c8774137fa3 Author: joylink_zhaoerwei Date: Wed Aug 21 17:37:48 2024 +0800 旋钮请求更改 commit 5313a00dc6de037052640b5c4179c36fbdf8a48a Author: fan Date: Wed Aug 21 16:57:21 2024 +0800 proto同步 commit f73b171f153cd170f3ff3236b4868d56f5622851 Author: joylink_zhaoerwei Date: Mon Aug 12 18:00:50 2024 +0800 计轴区段的显示和状态(待与后端测试) --- src/drawApp/graphics/TccKeyInteraction.ts | 8 +- src/drawApp/tccScene.ts | 8 +- src/protos/device_state.ts | 100 ++++++++++++---------- 3 files changed, 62 insertions(+), 54 deletions(-) diff --git a/src/drawApp/graphics/TccKeyInteraction.ts b/src/drawApp/graphics/TccKeyInteraction.ts index d8477c6..d5986dc 100644 --- a/src/drawApp/graphics/TccKeyInteraction.ts +++ b/src/drawApp/graphics/TccKeyInteraction.ts @@ -57,20 +57,20 @@ export class TccKeyData extends GraphicDataBase implements ITccKeyData { } export class TccKeyState extends GraphicStateBase implements ITccKeyState { - constructor(data?: state.TrainControlState.DirectionKeySwitch) { + constructor(data?: state.TrainControlState.SwitchKeyChange) { let tccKeyState; if (data) { tccKeyState = data; } else { - tccKeyState = new state.TrainControlState.DirectionKeySwitch(); + tccKeyState = new state.TrainControlState.SwitchKeyChange(); } super(tccKeyState, TccKey.Type); } get code(): string { return this.states.id + ''; } - get states(): state.TrainControlState.DirectionKeySwitch { - return this.getState(); + get states(): state.TrainControlState.SwitchKeyChange { + return this.getState(); } get position(): number { return this.states.val; diff --git a/src/drawApp/tccScene.ts b/src/drawApp/tccScene.ts index 093165d..b29b6b8 100644 --- a/src/drawApp/tccScene.ts +++ b/src/drawApp/tccScene.ts @@ -90,11 +90,11 @@ function handleSubscribe(tccScene: IGraphicScene) { storage?.buttons.forEach((button) => { states.push(new TccButtonState(button)); }); - if (storage.dirKey) { - states.push(new TccKeyState(storage.dirKey)); - } + storage?.switchKeys.forEach((switchKey) => { + states.push(new TccKeyState(switchKey)); + }); storage?.driverKey.forEach((driverKey) => { - const data = new state.TrainControlState.DirectionKeySwitch({ + const data = new state.TrainControlState.SwitchKeyChange({ id: driverKey.id, val: driverKey.val ? 1 : 0, }); diff --git a/src/protos/device_state.ts b/src/protos/device_state.ts index 551e1d2..a491e92 100644 --- a/src/protos/device_state.ts +++ b/src/protos/device_state.ts @@ -10614,7 +10614,7 @@ export namespace state { constructor(data?: any[] | { buttons?: Map; driverKey?: TrainControlState.DriverKeySwitch[]; - dirKey?: TrainControlState.DirectionKeySwitch; + switchKeyMap?: Map; pushHandler?: TrainControlState.PushHandler; lightMaps?: Map; lineInitTimeStamp12?: number; @@ -10629,8 +10629,8 @@ export namespace state { if ("driverKey" in data && data.driverKey != undefined) { this.driverKey = data.driverKey; } - if ("dirKey" in data && data.dirKey != undefined) { - this.dirKey = data.dirKey; + if ("switchKeyMap" in data && data.switchKeyMap != undefined) { + this.switchKeyMap = data.switchKeyMap; } if ("pushHandler" in data && data.pushHandler != undefined) { this.pushHandler = data.pushHandler; @@ -10647,6 +10647,8 @@ export namespace state { } if (!this.buttons) this.buttons = new Map(); + if (!this.switchKeyMap) + this.switchKeyMap = new Map(); if (!this.lightMaps) this.lightMaps = new Map(); } @@ -10662,14 +10664,11 @@ export namespace state { set driverKey(value: TrainControlState.DriverKeySwitch[]) { pb_1.Message.setRepeatedWrapperField(this, 2, value); } - get dirKey() { - return pb_1.Message.getWrapperField(this, TrainControlState.DirectionKeySwitch, 3) as TrainControlState.DirectionKeySwitch; + get switchKeyMap() { + return pb_1.Message.getField(this, 3) as any as Map; } - set dirKey(value: TrainControlState.DirectionKeySwitch) { - pb_1.Message.setWrapperField(this, 3, value); - } - get has_dirKey() { - return pb_1.Message.getField(this, 3) != null; + set switchKeyMap(value: Map) { + pb_1.Message.setField(this, 3, value as any); } get pushHandler() { return pb_1.Message.getWrapperField(this, TrainControlState.PushHandler, 4) as TrainControlState.PushHandler; @@ -10703,7 +10702,9 @@ export namespace state { [key: string]: ReturnType; }; driverKey?: ReturnType[]; - dirKey?: ReturnType; + switchKeyMap?: { + [key: string]: ReturnType; + }; pushHandler?: ReturnType; lightMaps?: { [key: string]: ReturnType; @@ -10718,8 +10719,8 @@ export namespace state { if (data.driverKey != null) { message.driverKey = data.driverKey.map(item => TrainControlState.DriverKeySwitch.fromObject(item)); } - if (data.dirKey != null) { - message.dirKey = TrainControlState.DirectionKeySwitch.fromObject(data.dirKey); + if (typeof data.switchKeyMap == "object") { + message.switchKeyMap = new Map(Object.entries(data.switchKeyMap).map(([key, value]) => [key, TrainControlState.SwitchKeyChange.fromObject(value)])); } if (data.pushHandler != null) { message.pushHandler = TrainControlState.PushHandler.fromObject(data.pushHandler); @@ -10741,7 +10742,9 @@ export namespace state { [key: string]: ReturnType; }; driverKey?: ReturnType[]; - dirKey?: ReturnType; + switchKeyMap?: { + [key: string]: ReturnType; + }; pushHandler?: ReturnType; lightMaps?: { [key: string]: ReturnType; @@ -10755,8 +10758,8 @@ export namespace state { if (this.driverKey != null) { data.driverKey = this.driverKey.map((item: TrainControlState.DriverKeySwitch) => item.toObject()); } - if (this.dirKey != null) { - data.dirKey = this.dirKey.toObject(); + if (this.switchKeyMap != null) { + data.switchKeyMap = (Object.fromEntries)((Array.from)(this.switchKeyMap).map(([key, value]) => [key, value.toObject()])); } if (this.pushHandler != null) { data.pushHandler = this.pushHandler.toObject(); @@ -10784,8 +10787,12 @@ export namespace state { } if (this.driverKey.length) writer.writeRepeatedMessage(2, this.driverKey, (item: TrainControlState.DriverKeySwitch) => item.serialize(writer)); - if (this.has_dirKey) - writer.writeMessage(3, this.dirKey, () => this.dirKey.serialize(writer)); + for (const [key, value] of this.switchKeyMap) { + writer.writeMessage(3, this.switchKeyMap, () => { + writer.writeString(1, key); + writer.writeMessage(2, value, () => value.serialize(writer)); + }); + } if (this.has_pushHandler) writer.writeMessage(4, this.pushHandler, () => this.pushHandler.serialize(writer)); for (const [key, value] of this.lightMaps) { @@ -10818,7 +10825,11 @@ export namespace state { reader.readMessage(message.driverKey, () => pb_1.Message.addToRepeatedWrapperField(message, 2, TrainControlState.DriverKeySwitch.deserialize(reader), TrainControlState.DriverKeySwitch)); break; case 3: - reader.readMessage(message.dirKey, () => message.dirKey = TrainControlState.DirectionKeySwitch.deserialize(reader)); + reader.readMessage(message, () => pb_1.Map.deserializeBinary(message.switchKeyMap as any, reader, reader.readString, () => { + let value; + reader.readMessage(message, () => value = TrainControlState.SwitchKeyChange.deserialize(reader)); + return value; + })); break; case 4: reader.readMessage(message.pushHandler, () => message.pushHandler = TrainControlState.PushHandler.deserialize(reader)); @@ -11029,7 +11040,7 @@ export namespace state { return DriverKeySwitch.deserialize(bytes); } } - export class DirectionKeySwitch extends pb_1.Message { + export class SwitchKeyChange extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { id?: number; @@ -11061,8 +11072,8 @@ export namespace state { static fromObject(data: { id?: number; val?: number; - }): DirectionKeySwitch { - const message = new DirectionKeySwitch({}); + }): SwitchKeyChange { + const message = new SwitchKeyChange({}); if (data.id != null) { message.id = data.id; } @@ -11095,8 +11106,8 @@ export namespace state { if (!w) return writer.getResultBuffer(); } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): DirectionKeySwitch { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new DirectionKeySwitch(); + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SwitchKeyChange { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SwitchKeyChange(); while (reader.nextField()) { if (reader.isEndGroup()) break; @@ -11115,8 +11126,8 @@ export namespace state { serializeBinary(): Uint8Array { return this.serialize(); } - static deserializeBinary(bytes: Uint8Array): DirectionKeySwitch { - return DirectionKeySwitch.deserialize(bytes); + static deserializeBinary(bytes: Uint8Array): SwitchKeyChange { + return SwitchKeyChange.deserialize(bytes); } } export class PushHandler extends pb_1.Message { @@ -11305,12 +11316,12 @@ export namespace state { constructor(data?: any[] | { buttons?: TrainControlState.ControlButton[]; driverKey?: TrainControlState.DriverKeySwitch[]; - dirKey?: TrainControlState.DirectionKeySwitch; + switchKeys?: TrainControlState.SwitchKeyChange[]; pushHandler?: TrainControlState.PushHandler; lights?: TrainControlState.ControlLight[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2, 5], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2, 3, 5], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("buttons" in data && data.buttons != undefined) { this.buttons = data.buttons; @@ -11318,8 +11329,8 @@ export namespace state { if ("driverKey" in data && data.driverKey != undefined) { this.driverKey = data.driverKey; } - if ("dirKey" in data && data.dirKey != undefined) { - this.dirKey = data.dirKey; + if ("switchKeys" in data && data.switchKeys != undefined) { + this.switchKeys = data.switchKeys; } if ("pushHandler" in data && data.pushHandler != undefined) { this.pushHandler = data.pushHandler; @@ -11341,14 +11352,11 @@ export namespace state { set driverKey(value: TrainControlState.DriverKeySwitch[]) { pb_1.Message.setRepeatedWrapperField(this, 2, value); } - get dirKey() { - return pb_1.Message.getWrapperField(this, TrainControlState.DirectionKeySwitch, 3) as TrainControlState.DirectionKeySwitch; + get switchKeys() { + return pb_1.Message.getRepeatedWrapperField(this, TrainControlState.SwitchKeyChange, 3) as TrainControlState.SwitchKeyChange[]; } - set dirKey(value: TrainControlState.DirectionKeySwitch) { - pb_1.Message.setWrapperField(this, 3, value); - } - get has_dirKey() { - return pb_1.Message.getField(this, 3) != null; + set switchKeys(value: TrainControlState.SwitchKeyChange[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); } get pushHandler() { return pb_1.Message.getWrapperField(this, TrainControlState.PushHandler, 4) as TrainControlState.PushHandler; @@ -11368,7 +11376,7 @@ export namespace state { static fromObject(data: { buttons?: ReturnType[]; driverKey?: ReturnType[]; - dirKey?: ReturnType; + switchKeys?: ReturnType[]; pushHandler?: ReturnType; lights?: ReturnType[]; }): TrainControlStateMsg { @@ -11379,8 +11387,8 @@ export namespace state { if (data.driverKey != null) { message.driverKey = data.driverKey.map(item => TrainControlState.DriverKeySwitch.fromObject(item)); } - if (data.dirKey != null) { - message.dirKey = TrainControlState.DirectionKeySwitch.fromObject(data.dirKey); + if (data.switchKeys != null) { + message.switchKeys = data.switchKeys.map(item => TrainControlState.SwitchKeyChange.fromObject(item)); } if (data.pushHandler != null) { message.pushHandler = TrainControlState.PushHandler.fromObject(data.pushHandler); @@ -11394,7 +11402,7 @@ export namespace state { const data: { buttons?: ReturnType[]; driverKey?: ReturnType[]; - dirKey?: ReturnType; + switchKeys?: ReturnType[]; pushHandler?: ReturnType; lights?: ReturnType[]; } = {}; @@ -11404,8 +11412,8 @@ export namespace state { if (this.driverKey != null) { data.driverKey = this.driverKey.map((item: TrainControlState.DriverKeySwitch) => item.toObject()); } - if (this.dirKey != null) { - data.dirKey = this.dirKey.toObject(); + if (this.switchKeys != null) { + data.switchKeys = this.switchKeys.map((item: TrainControlState.SwitchKeyChange) => item.toObject()); } if (this.pushHandler != null) { data.pushHandler = this.pushHandler.toObject(); @@ -11423,8 +11431,8 @@ export namespace state { writer.writeRepeatedMessage(1, this.buttons, (item: TrainControlState.ControlButton) => item.serialize(writer)); if (this.driverKey.length) writer.writeRepeatedMessage(2, this.driverKey, (item: TrainControlState.DriverKeySwitch) => item.serialize(writer)); - if (this.has_dirKey) - writer.writeMessage(3, this.dirKey, () => this.dirKey.serialize(writer)); + if (this.switchKeys.length) + writer.writeRepeatedMessage(3, this.switchKeys, (item: TrainControlState.SwitchKeyChange) => item.serialize(writer)); if (this.has_pushHandler) writer.writeMessage(4, this.pushHandler, () => this.pushHandler.serialize(writer)); if (this.lights.length) @@ -11445,7 +11453,7 @@ export namespace state { reader.readMessage(message.driverKey, () => pb_1.Message.addToRepeatedWrapperField(message, 2, TrainControlState.DriverKeySwitch.deserialize(reader), TrainControlState.DriverKeySwitch)); break; case 3: - reader.readMessage(message.dirKey, () => message.dirKey = TrainControlState.DirectionKeySwitch.deserialize(reader)); + reader.readMessage(message.switchKeys, () => pb_1.Message.addToRepeatedWrapperField(message, 3, TrainControlState.SwitchKeyChange.deserialize(reader), TrainControlState.SwitchKeyChange)); break; case 4: reader.readMessage(message.pushHandler, () => message.pushHandler = TrainControlState.PushHandler.deserialize(reader));