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

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 {
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<state.TrainControlState.DirectionKeySwitch>();
get states(): state.TrainControlState.SwitchKeyChange {
return this.getState<state.TrainControlState.SwitchKeyChange>();
}
get position(): number {
return this.states.val;

View File

@ -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,
});

View File

@ -10614,7 +10614,7 @@ export namespace state {
constructor(data?: any[] | {
buttons?: Map<string, TrainControlState.ControlButton>;
driverKey?: TrainControlState.DriverKeySwitch[];
dirKey?: TrainControlState.DirectionKeySwitch;
switchKeyMap?: Map<string, TrainControlState.SwitchKeyChange>;
pushHandler?: TrainControlState.PushHandler;
lightMaps?: Map<string, TrainControlState.ControlLight>;
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<string, 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 switchKeyMap(value: Map<string, TrainControlState.SwitchKeyChange>) {
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<typeof TrainControlState.ControlButton.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>;
lightMaps?: {
[key: string]: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>;
@ -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<typeof TrainControlState.ControlButton.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>;
lightMaps?: {
[key: string]: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>;
@ -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<typeof TrainControlState.ControlButton.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>;
lights?: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>[];
}): 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<typeof TrainControlState.ControlButton.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>;
lights?: ReturnType<typeof TrainControlState.ControlLight.prototype.toObject>[];
} = {};
@ -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));