解析proto

This commit is contained in:
fan 2023-10-19 17:57:53 +08:00
parent 7fcda79b8c
commit 0451397be2
6 changed files with 179 additions and 227 deletions

@ -1 +1 @@
Subproject commit cff3d23475a6352e560e27f7b006727b3b884217
Subproject commit 8e5d8faf7b16ddbc8cfdeb19f5a102cfdbac404b

View File

@ -117,18 +117,37 @@ export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslBut
g.eventMode = 'static';
g.cursor = 'pointer';
g.selectable = true;
g.on('mousedown', this.onMouseDown, this);
// g.on('mousedown', this.onMouseDown, this);
g.on('mouseup', this.onMouseUp, this);
}
unbind(g: PslButton): void {
g.selectable = false;
g.eventMode = 'none';
g.off('mousedown', this.onMouseDown, this);
// g.off('mousedown', this.onMouseDown, this);
g.on('mouseup', this.onMouseUp, this);
}
//FederatedMouseEvent
onMouseDown(e: FederatedMouseEvent) {
// onMouseDown(e: FederatedMouseEvent) {
// const simulationId = useLineStore().simulationId;
// const mapId = useLineStore().mapId;
// const gateBoxId = usePslStore().gatedBoxId;
// const target = e.target as DisplayObject;
// const pslButton = target.getGraphic() as PslButton;
// if (!simulationId || !mapId) {
// return;
// }
// pslOperate({
// simulationId,
// mapId,
// buttonCode: pslButton.datas.code,
// gateBoxId: gateBoxId,
// down: true,
// }).catch((err) => {
// errorNotify('操作失败', { message: err.origin.response.data.title });
// });
// }
onMouseUp(e: FederatedMouseEvent) {
const simulationId = useLineStore().simulationId;
const mapId = useLineStore().mapId;
const gateBoxId = usePslStore().gatedBoxId;
@ -147,23 +166,4 @@ export class PslButtonOperateInteraction extends GraphicInteractionPlugin<PslBut
errorNotify('操作失败', { message: err.origin.response.data.title });
});
}
onMouseUp(e: FederatedMouseEvent) {
const simulationId = useLineStore().simulationId;
const mapId = useLineStore().mapId;
const gateBoxId = usePslStore().gatedBoxId;
const target = e.target as DisplayObject;
const pslButton = target.getGraphic() as PslButton;
if (!simulationId || !mapId) {
return;
}
pslOperate({
simulationId,
mapId,
buttonCode: pslButton.datas.code,
gateBoxId: gateBoxId,
down: false,
}).catch((err) => {
errorNotify('操作失败', { message: err.origin.response.data.title });
});
}
}

View File

@ -65,7 +65,7 @@ function handleSubscribe(pslScene: IGraphicScene) {
app.subscribe({
destination: `simulation-psl-${simulationId}_${mapId}_${pslId}-status`,
messageConverter: (message: Uint8Array) => {
console.log('收到消息', message);
// console.log('收到消息', message);
const states: GraphicState[] = [];
// const storage = state.PushedDevicesStatus.deserialize(message);
// if (storage.all) {

View File

@ -2331,7 +2331,7 @@ export namespace state {
constructor(data?: any[] | {
id?: string;
down?: boolean;
aspect?: Signal.Aspect;
active?: boolean;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -2342,8 +2342,8 @@ export namespace state {
if ("down" in data && data.down != undefined) {
this.down = data.down;
}
if ("aspect" in data && data.aspect != undefined) {
this.aspect = data.aspect;
if ("active" in data && data.active != undefined) {
this.active = data.active;
}
}
}
@ -2359,16 +2359,16 @@ export namespace state {
set down(value: boolean) {
pb_1.Message.setField(this, 2, value);
}
get aspect() {
return pb_1.Message.getFieldWithDefault(this, 3, Signal.Aspect.Non) as Signal.Aspect;
get active() {
return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean;
}
set aspect(value: Signal.Aspect) {
set active(value: boolean) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
id?: string;
down?: boolean;
aspect?: Signal.Aspect;
active?: boolean;
}): ButtonState {
const message = new ButtonState({});
if (data.id != null) {
@ -2377,8 +2377,8 @@ export namespace state {
if (data.down != null) {
message.down = data.down;
}
if (data.aspect != null) {
message.aspect = data.aspect;
if (data.active != null) {
message.active = data.active;
}
return message;
}
@ -2386,7 +2386,7 @@ export namespace state {
const data: {
id?: string;
down?: boolean;
aspect?: Signal.Aspect;
active?: boolean;
} = {};
if (this.id != null) {
data.id = this.id;
@ -2394,8 +2394,8 @@ export namespace state {
if (this.down != null) {
data.down = this.down;
}
if (this.aspect != null) {
data.aspect = this.aspect;
if (this.active != null) {
data.active = this.active;
}
return data;
}
@ -2407,8 +2407,8 @@ export namespace state {
writer.writeString(1, this.id);
if (this.down != false)
writer.writeBool(2, this.down);
if (this.aspect != Signal.Aspect.Non)
writer.writeEnum(3, this.aspect);
if (this.active != false)
writer.writeBool(3, this.active);
if (!w)
return writer.getResultBuffer();
}
@ -2425,7 +2425,7 @@ export namespace state {
message.down = reader.readBool();
break;
case 3:
message.aspect = reader.readEnum();
message.active = reader.readBool();
break;
default: reader.skipField();
}
@ -2533,7 +2533,7 @@ export namespace state {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
id?: string;
aspect?: Signal.Aspect;
active?: boolean;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -2541,8 +2541,8 @@ export namespace state {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
if ("aspect" in data && data.aspect != undefined) {
this.aspect = data.aspect;
if ("active" in data && data.active != undefined) {
this.active = data.active;
}
}
}
@ -2552,35 +2552,35 @@ export namespace state {
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get aspect() {
return pb_1.Message.getFieldWithDefault(this, 2, Signal.Aspect.Non) as Signal.Aspect;
get active() {
return pb_1.Message.getFieldWithDefault(this, 2, false) as boolean;
}
set aspect(value: Signal.Aspect) {
set active(value: boolean) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
id?: string;
aspect?: Signal.Aspect;
active?: boolean;
}): LightState {
const message = new LightState({});
if (data.id != null) {
message.id = data.id;
}
if (data.aspect != null) {
message.aspect = data.aspect;
if (data.active != null) {
message.active = data.active;
}
return message;
}
toObject() {
const data: {
id?: string;
aspect?: Signal.Aspect;
active?: boolean;
} = {};
if (this.id != null) {
data.id = this.id;
}
if (this.aspect != null) {
data.aspect = this.aspect;
if (this.active != null) {
data.active = this.active;
}
return data;
}
@ -2590,8 +2590,8 @@ export namespace state {
const writer = w || new pb_1.BinaryWriter();
if (this.id.length)
writer.writeString(1, this.id);
if (this.aspect != Signal.Aspect.Non)
writer.writeEnum(2, this.aspect);
if (this.active != false)
writer.writeBool(2, this.active);
if (!w)
return writer.getResultBuffer();
}
@ -2605,7 +2605,7 @@ export namespace state {
message.id = reader.readString();
break;
case 2:
message.aspect = reader.readEnum();
message.active = reader.readBool();
break;
default: reader.skipField();
}
@ -2619,6 +2619,96 @@ export namespace state {
return LightState.deserialize(bytes);
}
}
export class PsdState extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
id?: string;
openDoorCodes?: number[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
if ("openDoorCodes" in data && data.openDoorCodes != undefined) {
this.openDoorCodes = data.openDoorCodes;
}
}
}
get id() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get openDoorCodes() {
return pb_1.Message.getFieldWithDefault(this, 2, []) as number[];
}
set openDoorCodes(value: number[]) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
id?: string;
openDoorCodes?: number[];
}): PsdState {
const message = new PsdState({});
if (data.id != null) {
message.id = data.id;
}
if (data.openDoorCodes != null) {
message.openDoorCodes = data.openDoorCodes;
}
return message;
}
toObject() {
const data: {
id?: string;
openDoorCodes?: number[];
} = {};
if (this.id != null) {
data.id = this.id;
}
if (this.openDoorCodes != null) {
data.openDoorCodes = this.openDoorCodes;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.id.length)
writer.writeString(1, this.id);
if (this.openDoorCodes.length)
writer.writePackedInt32(2, this.openDoorCodes);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): PsdState {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PsdState();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.id = reader.readString();
break;
case 2:
message.openDoorCodes = reader.readPackedInt32();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): PsdState {
return PsdState.deserialize(bytes);
}
}
export class VariationStatus extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
@ -2789,9 +2879,10 @@ export namespace state {
buttonState?: ButtonState[];
AlarmState?: AlarmState[];
LightState?: LightState[];
psdState?: PsdState[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2, 3, 4, 5, 6, 7, 8], this.#one_of_decls);
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2, 3, 4, 5, 6, 7, 8, 9], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("trainState" in data && data.trainState != undefined) {
this.trainState = data.trainState;
@ -2817,6 +2908,9 @@ export namespace state {
if ("LightState" in data && data.LightState != undefined) {
this.LightState = data.LightState;
}
if ("psdState" in data && data.psdState != undefined) {
this.psdState = data.psdState;
}
}
}
get trainState() {
@ -2867,6 +2961,12 @@ export namespace state {
set LightState(value: LightState[]) {
pb_1.Message.setRepeatedWrapperField(this, 8, value);
}
get psdState() {
return pb_1.Message.getRepeatedWrapperField(this, PsdState, 9) as PsdState[];
}
set psdState(value: PsdState[]) {
pb_1.Message.setRepeatedWrapperField(this, 9, value);
}
static fromObject(data: {
trainState?: ReturnType<typeof TrainState.prototype.toObject>[];
switchState?: ReturnType<typeof SwitchState.prototype.toObject>[];
@ -2876,6 +2976,7 @@ export namespace state {
buttonState?: ReturnType<typeof ButtonState.prototype.toObject>[];
AlarmState?: ReturnType<typeof AlarmState.prototype.toObject>[];
LightState?: ReturnType<typeof LightState.prototype.toObject>[];
psdState?: ReturnType<typeof PsdState.prototype.toObject>[];
}): AllDevicesStatus {
const message = new AllDevicesStatus({});
if (data.trainState != null) {
@ -2902,6 +3003,9 @@ export namespace state {
if (data.LightState != null) {
message.LightState = data.LightState.map(item => LightState.fromObject(item));
}
if (data.psdState != null) {
message.psdState = data.psdState.map(item => PsdState.fromObject(item));
}
return message;
}
toObject() {
@ -2914,6 +3018,7 @@ export namespace state {
buttonState?: ReturnType<typeof ButtonState.prototype.toObject>[];
AlarmState?: ReturnType<typeof AlarmState.prototype.toObject>[];
LightState?: ReturnType<typeof LightState.prototype.toObject>[];
psdState?: ReturnType<typeof PsdState.prototype.toObject>[];
} = {};
if (this.trainState != null) {
data.trainState = this.trainState.map((item: TrainState) => item.toObject());
@ -2939,6 +3044,9 @@ export namespace state {
if (this.LightState != null) {
data.LightState = this.LightState.map((item: LightState) => item.toObject());
}
if (this.psdState != null) {
data.psdState = this.psdState.map((item: PsdState) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
@ -2961,6 +3069,8 @@ export namespace state {
writer.writeRepeatedMessage(7, this.AlarmState, (item: AlarmState) => item.serialize(writer));
if (this.LightState.length)
writer.writeRepeatedMessage(8, this.LightState, (item: LightState) => item.serialize(writer));
if (this.psdState.length)
writer.writeRepeatedMessage(9, this.psdState, (item: PsdState) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
@ -2994,6 +3104,9 @@ export namespace state {
case 8:
reader.readMessage(message.LightState, () => pb_1.Message.addToRepeatedWrapperField(message, 8, LightState.deserialize(reader), LightState));
break;
case 9:
reader.readMessage(message.psdState, () => pb_1.Message.addToRepeatedWrapperField(message, 9, PsdState.deserialize(reader), PsdState));
break;
default: reader.skipField();
}
}

View File

@ -3,7 +3,6 @@
* compiler version: 4.23.1
* source: request.proto
* git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./device_state";
import * as pb_1 from "google-protobuf";
export namespace request {
export class Turnout extends pb_1.Message {
@ -251,163 +250,4 @@ export namespace request {
LightBCancelDs = 11
}
}
export class SignalOperationReq extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
simulationId?: string;
mapId?: number;
deviceId?: string;
operation?: Signal.Operation;
aspect?: dependency_1.state.Signal.Aspect;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("simulationId" in data && data.simulationId != undefined) {
this.simulationId = data.simulationId;
}
if ("mapId" in data && data.mapId != undefined) {
this.mapId = data.mapId;
}
if ("deviceId" in data && data.deviceId != undefined) {
this.deviceId = data.deviceId;
}
if ("operation" in data && data.operation != undefined) {
this.operation = data.operation;
}
if ("aspect" in data && data.aspect != undefined) {
this.aspect = data.aspect;
}
}
}
get simulationId() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set simulationId(value: string) {
pb_1.Message.setField(this, 1, value);
}
get mapId() {
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
}
set mapId(value: number) {
pb_1.Message.setField(this, 2, value);
}
get deviceId() {
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
}
set deviceId(value: string) {
pb_1.Message.setField(this, 3, value);
}
get operation() {
return pb_1.Message.getFieldWithDefault(this, 4, Signal.Operation.Undefined) as Signal.Operation;
}
set operation(value: Signal.Operation) {
pb_1.Message.setField(this, 4, value);
}
get aspect() {
return pb_1.Message.getFieldWithDefault(this, 5, dependency_1.state.Signal.Aspect.Non) as dependency_1.state.Signal.Aspect;
}
set aspect(value: dependency_1.state.Signal.Aspect) {
pb_1.Message.setField(this, 5, value);
}
static fromObject(data: {
simulationId?: string;
mapId?: number;
deviceId?: string;
operation?: Signal.Operation;
aspect?: dependency_1.state.Signal.Aspect;
}): SignalOperationReq {
const message = new SignalOperationReq({});
if (data.simulationId != null) {
message.simulationId = data.simulationId;
}
if (data.mapId != null) {
message.mapId = data.mapId;
}
if (data.deviceId != null) {
message.deviceId = data.deviceId;
}
if (data.operation != null) {
message.operation = data.operation;
}
if (data.aspect != null) {
message.aspect = data.aspect;
}
return message;
}
toObject() {
const data: {
simulationId?: string;
mapId?: number;
deviceId?: string;
operation?: Signal.Operation;
aspect?: dependency_1.state.Signal.Aspect;
} = {};
if (this.simulationId != null) {
data.simulationId = this.simulationId;
}
if (this.mapId != null) {
data.mapId = this.mapId;
}
if (this.deviceId != null) {
data.deviceId = this.deviceId;
}
if (this.operation != null) {
data.operation = this.operation;
}
if (this.aspect != null) {
data.aspect = this.aspect;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.simulationId.length)
writer.writeString(1, this.simulationId);
if (this.mapId != 0)
writer.writeInt32(2, this.mapId);
if (this.deviceId.length)
writer.writeString(3, this.deviceId);
if (this.operation != Signal.Operation.Undefined)
writer.writeEnum(4, this.operation);
if (this.aspect != dependency_1.state.Signal.Aspect.Non)
writer.writeEnum(5, this.aspect);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SignalOperationReq {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SignalOperationReq();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.simulationId = reader.readString();
break;
case 2:
message.mapId = reader.readInt32();
break;
case 3:
message.deviceId = reader.readString();
break;
case 4:
message.operation = reader.readEnum();
break;
case 5:
message.aspect = reader.readEnum();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): SignalOperationReq {
return SignalOperationReq.deserialize(bytes);
}
}
}

View File

@ -2798,7 +2798,7 @@ export namespace graphicData {
index?: number;
refDev?: RelatedRef;
centralizedStations?: string[];
mt?: Signal.ModelType;
mt?: Signal.Model;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [9], this.#one_of_decls);
@ -2881,9 +2881,9 @@ export namespace graphicData {
pb_1.Message.setField(this, 9, value);
}
get mt() {
return pb_1.Message.getFieldWithDefault(this, 10, Signal.ModelType.N) as Signal.ModelType;
return pb_1.Message.getFieldWithDefault(this, 10, Signal.Model.HLU) as Signal.Model;
}
set mt(value: Signal.ModelType) {
set mt(value: Signal.Model) {
pb_1.Message.setField(this, 10, value);
}
static fromObject(data: {
@ -2894,7 +2894,7 @@ export namespace graphicData {
index?: number;
refDev?: ReturnType<typeof RelatedRef.prototype.toObject>;
centralizedStations?: string[];
mt?: Signal.ModelType;
mt?: Signal.Model;
}): Signal {
const message = new Signal({});
if (data.common != null) {
@ -2932,7 +2932,7 @@ export namespace graphicData {
index?: number;
refDev?: ReturnType<typeof RelatedRef.prototype.toObject>;
centralizedStations?: string[];
mt?: Signal.ModelType;
mt?: Signal.Model;
} = {};
if (this.common != null) {
data.common = this.common.toObject();
@ -2978,7 +2978,7 @@ export namespace graphicData {
writer.writeMessage(8, this.refDev, () => this.refDev.serialize(writer));
if (this.centralizedStations.length)
writer.writeRepeatedString(9, this.centralizedStations);
if (this.mt != Signal.ModelType.N)
if (this.mt != Signal.Model.HLU)
writer.writeEnum(10, this.mt);
if (!w)
return writer.getResultBuffer();
@ -3026,14 +3026,13 @@ export namespace graphicData {
}
}
export namespace Signal {
export enum ModelType {
N = 0,
export enum Model {
HLU = 0,
HL = 1,
HLU_FU = 2,
HLU = 3,
HLU_FL = 4,
AB = 5,
HBU = 6
HLU_FL = 3,
AB = 4,
HBU = 5
}
}
export class Section extends pb_1.Message {