驾驶台接收信息修改(待与后端测试)

This commit is contained in:
joylink_zhaoerwei 2024-08-21 18:23:43 +08:00
parent fe56bdc27d
commit 1b85571005
3 changed files with 62 additions and 54 deletions

View File

@ -57,20 +57,20 @@ export class TccKeyData extends GraphicDataBase implements ITccKeyData {
} }
export class TccKeyState extends GraphicStateBase implements ITccKeyState { export class TccKeyState extends GraphicStateBase implements ITccKeyState {
constructor(data?: state.TrainControlState.DirectionKeySwitch) { constructor(data?: state.TrainControlState.SwitchKeyChange) {
let tccKeyState; let tccKeyState;
if (data) { if (data) {
tccKeyState = data; tccKeyState = data;
} else { } else {
tccKeyState = new state.TrainControlState.DirectionKeySwitch(); tccKeyState = new state.TrainControlState.SwitchKeyChange();
} }
super(tccKeyState, TccKey.Type); super(tccKeyState, TccKey.Type);
} }
get code(): string { get code(): string {
return this.states.id + ''; return this.states.id + '';
} }
get states(): state.TrainControlState.DirectionKeySwitch { get states(): state.TrainControlState.SwitchKeyChange {
return this.getState<state.TrainControlState.DirectionKeySwitch>(); return this.getState<state.TrainControlState.SwitchKeyChange>();
} }
get position(): number { get position(): number {
return this.states.val; return this.states.val;

View File

@ -90,11 +90,11 @@ function handleSubscribe(tccScene: IGraphicScene) {
storage?.buttons.forEach((button) => { storage?.buttons.forEach((button) => {
states.push(new TccButtonState(button)); states.push(new TccButtonState(button));
}); });
if (storage.dirKey) { storage?.switchKeys.forEach((switchKey) => {
states.push(new TccKeyState(storage.dirKey)); states.push(new TccKeyState(switchKey));
} });
storage?.driverKey.forEach((driverKey) => { storage?.driverKey.forEach((driverKey) => {
const data = new state.TrainControlState.DirectionKeySwitch({ const data = new state.TrainControlState.SwitchKeyChange({
id: driverKey.id, id: driverKey.id,
val: driverKey.val ? 1 : 0, val: driverKey.val ? 1 : 0,
}); });

View File

@ -10614,7 +10614,7 @@ export namespace state {
constructor(data?: any[] | { constructor(data?: any[] | {
buttons?: Map<string, TrainControlState.ControlButton>; buttons?: Map<string, TrainControlState.ControlButton>;
driverKey?: TrainControlState.DriverKeySwitch[]; driverKey?: TrainControlState.DriverKeySwitch[];
dirKey?: TrainControlState.DirectionKeySwitch; switchKeyMap?: Map<string, TrainControlState.SwitchKeyChange>;
pushHandler?: TrainControlState.PushHandler; pushHandler?: TrainControlState.PushHandler;
lightMaps?: Map<string, TrainControlState.ControlLight>; lightMaps?: Map<string, TrainControlState.ControlLight>;
lineInitTimeStamp12?: number; lineInitTimeStamp12?: number;
@ -10629,8 +10629,8 @@ export namespace state {
if ("driverKey" in data && data.driverKey != undefined) { if ("driverKey" in data && data.driverKey != undefined) {
this.driverKey = data.driverKey; this.driverKey = data.driverKey;
} }
if ("dirKey" in data && data.dirKey != undefined) { if ("switchKeyMap" in data && data.switchKeyMap != undefined) {
this.dirKey = data.dirKey; this.switchKeyMap = data.switchKeyMap;
} }
if ("pushHandler" in data && data.pushHandler != undefined) { if ("pushHandler" in data && data.pushHandler != undefined) {
this.pushHandler = data.pushHandler; this.pushHandler = data.pushHandler;
@ -10647,6 +10647,8 @@ export namespace state {
} }
if (!this.buttons) if (!this.buttons)
this.buttons = new Map(); this.buttons = new Map();
if (!this.switchKeyMap)
this.switchKeyMap = new Map();
if (!this.lightMaps) if (!this.lightMaps)
this.lightMaps = new Map(); this.lightMaps = new Map();
} }
@ -10662,14 +10664,11 @@ export namespace state {
set driverKey(value: TrainControlState.DriverKeySwitch[]) { set driverKey(value: TrainControlState.DriverKeySwitch[]) {
pb_1.Message.setRepeatedWrapperField(this, 2, value); pb_1.Message.setRepeatedWrapperField(this, 2, value);
} }
get dirKey() { get switchKeyMap() {
return pb_1.Message.getWrapperField(this, TrainControlState.DirectionKeySwitch, 3) as TrainControlState.DirectionKeySwitch; return pb_1.Message.getField(this, 3) as any as Map<string, TrainControlState.SwitchKeyChange>;
} }
set dirKey(value: TrainControlState.DirectionKeySwitch) { set switchKeyMap(value: Map<string, TrainControlState.SwitchKeyChange>) {
pb_1.Message.setWrapperField(this, 3, value); pb_1.Message.setField(this, 3, value as any);
}
get has_dirKey() {
return pb_1.Message.getField(this, 3) != null;
} }
get pushHandler() { get pushHandler() {
return pb_1.Message.getWrapperField(this, TrainControlState.PushHandler, 4) as TrainControlState.PushHandler; return pb_1.Message.getWrapperField(this, TrainControlState.PushHandler, 4) as TrainControlState.PushHandler;
@ -10703,7 +10702,9 @@ export namespace state {
[key: string]: ReturnType<typeof TrainControlState.ControlButton.prototype.toObject>; [key: string]: ReturnType<typeof TrainControlState.ControlButton.prototype.toObject>;
}; };
driverKey?: ReturnType<typeof TrainControlState.DriverKeySwitch.prototype.toObject>[]; driverKey?: ReturnType<typeof TrainControlState.DriverKeySwitch.prototype.toObject>[];
dirKey?: ReturnType<typeof TrainControlState.DirectionKeySwitch.prototype.toObject>; switchKeyMap?: {
[key: string]: ReturnType<typeof TrainControlState.SwitchKeyChange.prototype.toObject>;
};
pushHandler?: ReturnType<typeof TrainControlState.PushHandler.prototype.toObject>; pushHandler?: ReturnType<typeof TrainControlState.PushHandler.prototype.toObject>;
lightMaps?: { lightMaps?: {
[key: string]: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>; [key: string]: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>;
@ -10718,8 +10719,8 @@ export namespace state {
if (data.driverKey != null) { if (data.driverKey != null) {
message.driverKey = data.driverKey.map(item => TrainControlState.DriverKeySwitch.fromObject(item)); message.driverKey = data.driverKey.map(item => TrainControlState.DriverKeySwitch.fromObject(item));
} }
if (data.dirKey != null) { if (typeof data.switchKeyMap == "object") {
message.dirKey = TrainControlState.DirectionKeySwitch.fromObject(data.dirKey); message.switchKeyMap = new Map(Object.entries(data.switchKeyMap).map(([key, value]) => [key, TrainControlState.SwitchKeyChange.fromObject(value)]));
} }
if (data.pushHandler != null) { if (data.pushHandler != null) {
message.pushHandler = TrainControlState.PushHandler.fromObject(data.pushHandler); message.pushHandler = TrainControlState.PushHandler.fromObject(data.pushHandler);
@ -10741,7 +10742,9 @@ export namespace state {
[key: string]: ReturnType<typeof TrainControlState.ControlButton.prototype.toObject>; [key: string]: ReturnType<typeof TrainControlState.ControlButton.prototype.toObject>;
}; };
driverKey?: ReturnType<typeof TrainControlState.DriverKeySwitch.prototype.toObject>[]; driverKey?: ReturnType<typeof TrainControlState.DriverKeySwitch.prototype.toObject>[];
dirKey?: ReturnType<typeof TrainControlState.DirectionKeySwitch.prototype.toObject>; switchKeyMap?: {
[key: string]: ReturnType<typeof TrainControlState.SwitchKeyChange.prototype.toObject>;
};
pushHandler?: ReturnType<typeof TrainControlState.PushHandler.prototype.toObject>; pushHandler?: ReturnType<typeof TrainControlState.PushHandler.prototype.toObject>;
lightMaps?: { lightMaps?: {
[key: string]: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>; [key: string]: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>;
@ -10755,8 +10758,8 @@ export namespace state {
if (this.driverKey != null) { if (this.driverKey != null) {
data.driverKey = this.driverKey.map((item: TrainControlState.DriverKeySwitch) => item.toObject()); data.driverKey = this.driverKey.map((item: TrainControlState.DriverKeySwitch) => item.toObject());
} }
if (this.dirKey != null) { if (this.switchKeyMap != null) {
data.dirKey = this.dirKey.toObject(); data.switchKeyMap = (Object.fromEntries)((Array.from)(this.switchKeyMap).map(([key, value]) => [key, value.toObject()]));
} }
if (this.pushHandler != null) { if (this.pushHandler != null) {
data.pushHandler = this.pushHandler.toObject(); data.pushHandler = this.pushHandler.toObject();
@ -10784,8 +10787,12 @@ export namespace state {
} }
if (this.driverKey.length) if (this.driverKey.length)
writer.writeRepeatedMessage(2, this.driverKey, (item: TrainControlState.DriverKeySwitch) => item.serialize(writer)); writer.writeRepeatedMessage(2, this.driverKey, (item: TrainControlState.DriverKeySwitch) => item.serialize(writer));
if (this.has_dirKey) for (const [key, value] of this.switchKeyMap) {
writer.writeMessage(3, this.dirKey, () => this.dirKey.serialize(writer)); writer.writeMessage(3, this.switchKeyMap, () => {
writer.writeString(1, key);
writer.writeMessage(2, value, () => value.serialize(writer));
});
}
if (this.has_pushHandler) if (this.has_pushHandler)
writer.writeMessage(4, this.pushHandler, () => this.pushHandler.serialize(writer)); writer.writeMessage(4, this.pushHandler, () => this.pushHandler.serialize(writer));
for (const [key, value] of this.lightMaps) { 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)); reader.readMessage(message.driverKey, () => pb_1.Message.addToRepeatedWrapperField(message, 2, TrainControlState.DriverKeySwitch.deserialize(reader), TrainControlState.DriverKeySwitch));
break; break;
case 3: 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; break;
case 4: case 4:
reader.readMessage(message.pushHandler, () => message.pushHandler = TrainControlState.PushHandler.deserialize(reader)); reader.readMessage(message.pushHandler, () => message.pushHandler = TrainControlState.PushHandler.deserialize(reader));
@ -11029,7 +11040,7 @@ export namespace state {
return DriverKeySwitch.deserialize(bytes); return DriverKeySwitch.deserialize(bytes);
} }
} }
export class DirectionKeySwitch extends pb_1.Message { export class SwitchKeyChange extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | { constructor(data?: any[] | {
id?: number; id?: number;
@ -11061,8 +11072,8 @@ export namespace state {
static fromObject(data: { static fromObject(data: {
id?: number; id?: number;
val?: number; val?: number;
}): DirectionKeySwitch { }): SwitchKeyChange {
const message = new DirectionKeySwitch({}); const message = new SwitchKeyChange({});
if (data.id != null) { if (data.id != null) {
message.id = data.id; message.id = data.id;
} }
@ -11095,8 +11106,8 @@ export namespace state {
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): DirectionKeySwitch { static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SwitchKeyChange {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new DirectionKeySwitch(); const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SwitchKeyChange();
while (reader.nextField()) { while (reader.nextField()) {
if (reader.isEndGroup()) if (reader.isEndGroup())
break; break;
@ -11115,8 +11126,8 @@ export namespace state {
serializeBinary(): Uint8Array { serializeBinary(): Uint8Array {
return this.serialize(); return this.serialize();
} }
static deserializeBinary(bytes: Uint8Array): DirectionKeySwitch { static deserializeBinary(bytes: Uint8Array): SwitchKeyChange {
return DirectionKeySwitch.deserialize(bytes); return SwitchKeyChange.deserialize(bytes);
} }
} }
export class PushHandler extends pb_1.Message { export class PushHandler extends pb_1.Message {
@ -11305,12 +11316,12 @@ export namespace state {
constructor(data?: any[] | { constructor(data?: any[] | {
buttons?: TrainControlState.ControlButton[]; buttons?: TrainControlState.ControlButton[];
driverKey?: TrainControlState.DriverKeySwitch[]; driverKey?: TrainControlState.DriverKeySwitch[];
dirKey?: TrainControlState.DirectionKeySwitch; switchKeys?: TrainControlState.SwitchKeyChange[];
pushHandler?: TrainControlState.PushHandler; pushHandler?: TrainControlState.PushHandler;
lights?: TrainControlState.ControlLight[]; lights?: TrainControlState.ControlLight[];
}) { }) {
super(); 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 (!Array.isArray(data) && typeof data == "object") {
if ("buttons" in data && data.buttons != undefined) { if ("buttons" in data && data.buttons != undefined) {
this.buttons = data.buttons; this.buttons = data.buttons;
@ -11318,8 +11329,8 @@ export namespace state {
if ("driverKey" in data && data.driverKey != undefined) { if ("driverKey" in data && data.driverKey != undefined) {
this.driverKey = data.driverKey; this.driverKey = data.driverKey;
} }
if ("dirKey" in data && data.dirKey != undefined) { if ("switchKeys" in data && data.switchKeys != undefined) {
this.dirKey = data.dirKey; this.switchKeys = data.switchKeys;
} }
if ("pushHandler" in data && data.pushHandler != undefined) { if ("pushHandler" in data && data.pushHandler != undefined) {
this.pushHandler = data.pushHandler; this.pushHandler = data.pushHandler;
@ -11341,14 +11352,11 @@ export namespace state {
set driverKey(value: TrainControlState.DriverKeySwitch[]) { set driverKey(value: TrainControlState.DriverKeySwitch[]) {
pb_1.Message.setRepeatedWrapperField(this, 2, value); pb_1.Message.setRepeatedWrapperField(this, 2, value);
} }
get dirKey() { get switchKeys() {
return pb_1.Message.getWrapperField(this, TrainControlState.DirectionKeySwitch, 3) as TrainControlState.DirectionKeySwitch; return pb_1.Message.getRepeatedWrapperField(this, TrainControlState.SwitchKeyChange, 3) as TrainControlState.SwitchKeyChange[];
} }
set dirKey(value: TrainControlState.DirectionKeySwitch) { set switchKeys(value: TrainControlState.SwitchKeyChange[]) {
pb_1.Message.setWrapperField(this, 3, value); pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
get has_dirKey() {
return pb_1.Message.getField(this, 3) != null;
} }
get pushHandler() { get pushHandler() {
return pb_1.Message.getWrapperField(this, TrainControlState.PushHandler, 4) as TrainControlState.PushHandler; return pb_1.Message.getWrapperField(this, TrainControlState.PushHandler, 4) as TrainControlState.PushHandler;
@ -11368,7 +11376,7 @@ export namespace state {
static fromObject(data: { static fromObject(data: {
buttons?: ReturnType<typeof TrainControlState.ControlButton.prototype.toObject>[]; buttons?: ReturnType<typeof TrainControlState.ControlButton.prototype.toObject>[];
driverKey?: ReturnType<typeof TrainControlState.DriverKeySwitch.prototype.toObject>[]; driverKey?: ReturnType<typeof TrainControlState.DriverKeySwitch.prototype.toObject>[];
dirKey?: ReturnType<typeof TrainControlState.DirectionKeySwitch.prototype.toObject>; switchKeys?: ReturnType<typeof TrainControlState.SwitchKeyChange.prototype.toObject>[];
pushHandler?: ReturnType<typeof TrainControlState.PushHandler.prototype.toObject>; pushHandler?: ReturnType<typeof TrainControlState.PushHandler.prototype.toObject>;
lights?: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>[]; lights?: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>[];
}): TrainControlStateMsg { }): TrainControlStateMsg {
@ -11379,8 +11387,8 @@ export namespace state {
if (data.driverKey != null) { if (data.driverKey != null) {
message.driverKey = data.driverKey.map(item => TrainControlState.DriverKeySwitch.fromObject(item)); message.driverKey = data.driverKey.map(item => TrainControlState.DriverKeySwitch.fromObject(item));
} }
if (data.dirKey != null) { if (data.switchKeys != null) {
message.dirKey = TrainControlState.DirectionKeySwitch.fromObject(data.dirKey); message.switchKeys = data.switchKeys.map(item => TrainControlState.SwitchKeyChange.fromObject(item));
} }
if (data.pushHandler != null) { if (data.pushHandler != null) {
message.pushHandler = TrainControlState.PushHandler.fromObject(data.pushHandler); message.pushHandler = TrainControlState.PushHandler.fromObject(data.pushHandler);
@ -11394,7 +11402,7 @@ export namespace state {
const data: { const data: {
buttons?: ReturnType<typeof TrainControlState.ControlButton.prototype.toObject>[]; buttons?: ReturnType<typeof TrainControlState.ControlButton.prototype.toObject>[];
driverKey?: ReturnType<typeof TrainControlState.DriverKeySwitch.prototype.toObject>[]; driverKey?: ReturnType<typeof TrainControlState.DriverKeySwitch.prototype.toObject>[];
dirKey?: ReturnType<typeof TrainControlState.DirectionKeySwitch.prototype.toObject>; switchKeys?: ReturnType<typeof TrainControlState.SwitchKeyChange.prototype.toObject>[];
pushHandler?: ReturnType<typeof TrainControlState.PushHandler.prototype.toObject>; pushHandler?: ReturnType<typeof TrainControlState.PushHandler.prototype.toObject>;
lights?: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>[]; lights?: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>[];
} = {}; } = {};
@ -11404,8 +11412,8 @@ export namespace state {
if (this.driverKey != null) { if (this.driverKey != null) {
data.driverKey = this.driverKey.map((item: TrainControlState.DriverKeySwitch) => item.toObject()); data.driverKey = this.driverKey.map((item: TrainControlState.DriverKeySwitch) => item.toObject());
} }
if (this.dirKey != null) { if (this.switchKeys != null) {
data.dirKey = this.dirKey.toObject(); data.switchKeys = this.switchKeys.map((item: TrainControlState.SwitchKeyChange) => item.toObject());
} }
if (this.pushHandler != null) { if (this.pushHandler != null) {
data.pushHandler = this.pushHandler.toObject(); data.pushHandler = this.pushHandler.toObject();
@ -11423,8 +11431,8 @@ export namespace state {
writer.writeRepeatedMessage(1, this.buttons, (item: TrainControlState.ControlButton) => item.serialize(writer)); writer.writeRepeatedMessage(1, this.buttons, (item: TrainControlState.ControlButton) => item.serialize(writer));
if (this.driverKey.length) if (this.driverKey.length)
writer.writeRepeatedMessage(2, this.driverKey, (item: TrainControlState.DriverKeySwitch) => item.serialize(writer)); writer.writeRepeatedMessage(2, this.driverKey, (item: TrainControlState.DriverKeySwitch) => item.serialize(writer));
if (this.has_dirKey) if (this.switchKeys.length)
writer.writeMessage(3, this.dirKey, () => this.dirKey.serialize(writer)); writer.writeRepeatedMessage(3, this.switchKeys, (item: TrainControlState.SwitchKeyChange) => item.serialize(writer));
if (this.has_pushHandler) if (this.has_pushHandler)
writer.writeMessage(4, this.pushHandler, () => this.pushHandler.serialize(writer)); writer.writeMessage(4, this.pushHandler, () => this.pushHandler.serialize(writer));
if (this.lights.length) 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)); reader.readMessage(message.driverKey, () => pb_1.Message.addToRepeatedWrapperField(message, 2, TrainControlState.DriverKeySwitch.deserialize(reader), TrainControlState.DriverKeySwitch));
break; break;
case 3: 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; break;
case 4: case 4:
reader.readMessage(message.pushHandler, () => message.pushHandler = TrainControlState.PushHandler.deserialize(reader)); reader.readMessage(message.pushHandler, () => message.pushHandler = TrainControlState.PushHandler.deserialize(reader));