This commit is contained in:
joylink_fanyuhong 2024-08-22 08:41:59 +08:00
commit 191203c274
6 changed files with 93 additions and 84 deletions

View File

@ -191,7 +191,7 @@ export interface TccOperationParams {
controlType: request.TrainControl.TrainControlType;
controlButton?: object;
driverKey?: object;
dirKey?: object;
switchKey?: object;
handler?: object;
}
export async function tccOperation(params: TccOperationParams) {

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));

View File

@ -1423,7 +1423,7 @@ export namespace request {
controlType?: TrainControl.TrainControlType;
controlButton?: TrainControl.ControlButton;
driverKey?: TrainControl.DriverKeySwitch;
dirKey?: TrainControl.DirectionKeySwitch;
switchKey?: TrainControl.SwitchKeyChange;
handler?: TrainControl.PushHandler;
}) {
super();
@ -1447,8 +1447,8 @@ export namespace request {
if ("driverKey" in data && data.driverKey != undefined) {
this.driverKey = data.driverKey;
}
if ("dirKey" in data && data.dirKey != undefined) {
this.dirKey = data.dirKey;
if ("switchKey" in data && data.switchKey != undefined) {
this.switchKey = data.switchKey;
}
if ("handler" in data && data.handler != undefined) {
this.handler = data.handler;
@ -1497,13 +1497,13 @@ export namespace request {
get has_driverKey() {
return pb_1.Message.getField(this, 6) != null;
}
get dirKey() {
return pb_1.Message.getWrapperField(this, TrainControl.DirectionKeySwitch, 7) as TrainControl.DirectionKeySwitch;
get switchKey() {
return pb_1.Message.getWrapperField(this, TrainControl.SwitchKeyChange, 7) as TrainControl.SwitchKeyChange;
}
set dirKey(value: TrainControl.DirectionKeySwitch) {
set switchKey(value: TrainControl.SwitchKeyChange) {
pb_1.Message.setWrapperField(this, 7, value);
}
get has_dirKey() {
get has_switchKey() {
return pb_1.Message.getField(this, 7) != null;
}
get handler() {
@ -1522,7 +1522,7 @@ export namespace request {
controlType?: TrainControl.TrainControlType;
controlButton?: ReturnType<typeof TrainControl.ControlButton.prototype.toObject>;
driverKey?: ReturnType<typeof TrainControl.DriverKeySwitch.prototype.toObject>;
dirKey?: ReturnType<typeof TrainControl.DirectionKeySwitch.prototype.toObject>;
switchKey?: ReturnType<typeof TrainControl.SwitchKeyChange.prototype.toObject>;
handler?: ReturnType<typeof TrainControl.PushHandler.prototype.toObject>;
}): TrainControl {
const message = new TrainControl({});
@ -1544,8 +1544,8 @@ export namespace request {
if (data.driverKey != null) {
message.driverKey = TrainControl.DriverKeySwitch.fromObject(data.driverKey);
}
if (data.dirKey != null) {
message.dirKey = TrainControl.DirectionKeySwitch.fromObject(data.dirKey);
if (data.switchKey != null) {
message.switchKey = TrainControl.SwitchKeyChange.fromObject(data.switchKey);
}
if (data.handler != null) {
message.handler = TrainControl.PushHandler.fromObject(data.handler);
@ -1560,7 +1560,7 @@ export namespace request {
controlType?: TrainControl.TrainControlType;
controlButton?: ReturnType<typeof TrainControl.ControlButton.prototype.toObject>;
driverKey?: ReturnType<typeof TrainControl.DriverKeySwitch.prototype.toObject>;
dirKey?: ReturnType<typeof TrainControl.DirectionKeySwitch.prototype.toObject>;
switchKey?: ReturnType<typeof TrainControl.SwitchKeyChange.prototype.toObject>;
handler?: ReturnType<typeof TrainControl.PushHandler.prototype.toObject>;
} = {};
if (this.simulationId != null) {
@ -1581,8 +1581,8 @@ export namespace request {
if (this.driverKey != null) {
data.driverKey = this.driverKey.toObject();
}
if (this.dirKey != null) {
data.dirKey = this.dirKey.toObject();
if (this.switchKey != null) {
data.switchKey = this.switchKey.toObject();
}
if (this.handler != null) {
data.handler = this.handler.toObject();
@ -1605,8 +1605,8 @@ export namespace request {
writer.writeMessage(5, this.controlButton, () => this.controlButton.serialize(writer));
if (this.has_driverKey)
writer.writeMessage(6, this.driverKey, () => this.driverKey.serialize(writer));
if (this.has_dirKey)
writer.writeMessage(7, this.dirKey, () => this.dirKey.serialize(writer));
if (this.has_switchKey)
writer.writeMessage(7, this.switchKey, () => this.switchKey.serialize(writer));
if (this.has_handler)
writer.writeMessage(8, this.handler, () => this.handler.serialize(writer));
if (!w)
@ -1637,7 +1637,7 @@ export namespace request {
reader.readMessage(message.driverKey, () => message.driverKey = TrainControl.DriverKeySwitch.deserialize(reader));
break;
case 7:
reader.readMessage(message.dirKey, () => message.dirKey = TrainControl.DirectionKeySwitch.deserialize(reader));
reader.readMessage(message.switchKey, () => message.switchKey = TrainControl.SwitchKeyChange.deserialize(reader));
break;
case 8:
reader.readMessage(message.handler, () => message.handler = TrainControl.PushHandler.deserialize(reader));
@ -1659,12 +1659,13 @@ export namespace request {
EMERGENT_BUTTON = 0,
DRIVER_KEY_SWITCH = 1,
DIRECTION_KEY_SWITCH = 2,
HANDLER = 3
HANDLER = 3,
TRAIN_DOOR_MODE_CHANGE = 4
}
export enum Direction {
BACKWARD = 0,
FORWARD = 1,
NEUTRALWARD = 2
export enum KeyLocation {
KL_END = 0,
KL_FONT = 1,
KL_CENTER = 2
}
export class ControlButton extends pb_1.Message {
#one_of_decls: number[][] = [];
@ -1867,7 +1868,7 @@ export namespace request {
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[] | {
val?: number;
@ -1888,8 +1889,8 @@ export namespace request {
}
static fromObject(data: {
val?: number;
}): DirectionKeySwitch {
const message = new DirectionKeySwitch({});
}): SwitchKeyChange {
const message = new SwitchKeyChange({});
if (data.val != null) {
message.val = data.val;
}
@ -1913,8 +1914,8 @@ export namespace request {
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;
@ -1930,8 +1931,8 @@ export namespace request {
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 {

View File

@ -85,7 +85,7 @@ export const useTccStore = defineStore('tcc', {
trainId: this.tccId + '',
deviceId: this.tccKeyDirId,
controlType: request.TrainControl.TrainControlType.DIRECTION_KEY_SWITCH,
dirKey: {
switchKey: {
val: position,
},
})