From 507ddc5c45da3f9aeb5f8d4e8796c06a55b5ca36 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Fri, 14 Jul 2023 14:07:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?proto=E5=90=8C=E6=AD=A5=E5=92=8C=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E6=8E=89=E5=A4=9A=E4=BD=99=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/protos/device_state.ts | 119 ++++ src/protos/stationLayoutGraphics.ts | 907 +--------------------------- 2 files changed, 120 insertions(+), 906 deletions(-) diff --git a/src/protos/device_state.ts b/src/protos/device_state.ts index 6301baa..d108664 100644 --- a/src/protos/device_state.ts +++ b/src/protos/device_state.ts @@ -758,4 +758,123 @@ export namespace state { return AllDevicesStatus.deserialize(bytes); } } + export class PushedDevicesStatus extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + all?: boolean; + varStatus?: VariationStatus; + allStatus?: AllDevicesStatus; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("all" in data && data.all != undefined) { + this.all = data.all; + } + if ("varStatus" in data && data.varStatus != undefined) { + this.varStatus = data.varStatus; + } + if ("allStatus" in data && data.allStatus != undefined) { + this.allStatus = data.allStatus; + } + } + } + get all() { + return pb_1.Message.getFieldWithDefault(this, 1, false) as boolean; + } + set all(value: boolean) { + pb_1.Message.setField(this, 1, value); + } + get varStatus() { + return pb_1.Message.getWrapperField(this, VariationStatus, 2) as VariationStatus; + } + set varStatus(value: VariationStatus) { + pb_1.Message.setWrapperField(this, 2, value); + } + get has_varStatus() { + return pb_1.Message.getField(this, 2) != null; + } + get allStatus() { + return pb_1.Message.getWrapperField(this, AllDevicesStatus, 3) as AllDevicesStatus; + } + set allStatus(value: AllDevicesStatus) { + pb_1.Message.setWrapperField(this, 3, value); + } + get has_allStatus() { + return pb_1.Message.getField(this, 3) != null; + } + static fromObject(data: { + all?: boolean; + varStatus?: ReturnType; + allStatus?: ReturnType; + }): PushedDevicesStatus { + const message = new PushedDevicesStatus({}); + if (data.all != null) { + message.all = data.all; + } + if (data.varStatus != null) { + message.varStatus = VariationStatus.fromObject(data.varStatus); + } + if (data.allStatus != null) { + message.allStatus = AllDevicesStatus.fromObject(data.allStatus); + } + return message; + } + toObject() { + const data: { + all?: boolean; + varStatus?: ReturnType; + allStatus?: ReturnType; + } = {}; + if (this.all != null) { + data.all = this.all; + } + if (this.varStatus != null) { + data.varStatus = this.varStatus.toObject(); + } + if (this.allStatus != null) { + data.allStatus = this.allStatus.toObject(); + } + 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.all != false) + writer.writeBool(1, this.all); + if (this.has_varStatus) + writer.writeMessage(2, this.varStatus, () => this.varStatus.serialize(writer)); + if (this.has_allStatus) + writer.writeMessage(3, this.allStatus, () => this.allStatus.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): PushedDevicesStatus { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PushedDevicesStatus(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.all = reader.readBool(); + break; + case 2: + reader.readMessage(message.varStatus, () => message.varStatus = VariationStatus.deserialize(reader)); + break; + case 3: + reader.readMessage(message.allStatus, () => message.allStatus = AllDevicesStatus.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): PushedDevicesStatus { + return PushedDevicesStatus.deserialize(bytes); + } + } } diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 6ce2ec6..7093fea 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -9,16 +9,11 @@ export namespace graphicData { #one_of_decls: number[][] = []; constructor(data?: any[] | { canvas?: Canvas; - links?: Link[]; - iscsFans?: IscsFan[]; Platforms?: Platform[]; stations?: Station[]; - rects?: Rect[]; - train?: Train[]; signals?: Signal[]; turnouts?: Turnout[]; section?: Section[]; - polygons?: Polygon[]; trainWindows?: TrainWindow[]; axleCountings?: AxleCounting[]; separators?: Separator[]; @@ -27,29 +22,17 @@ export namespace graphicData { logicSections?: LogicSection[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5, 8, 9, 10, 12, 13, 14, 15, 16, 17], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; } - if ("links" in data && data.links != undefined) { - this.links = data.links; - } - if ("iscsFans" in data && data.iscsFans != undefined) { - this.iscsFans = data.iscsFans; - } if ("Platforms" in data && data.Platforms != undefined) { this.Platforms = data.Platforms; } if ("stations" in data && data.stations != undefined) { this.stations = data.stations; } - if ("rects" in data && data.rects != undefined) { - this.rects = data.rects; - } - if ("train" in data && data.train != undefined) { - this.train = data.train; - } if ("signals" in data && data.signals != undefined) { this.signals = data.signals; } @@ -59,9 +42,6 @@ export namespace graphicData { if ("section" in data && data.section != undefined) { this.section = data.section; } - if ("polygons" in data && data.polygons != undefined) { - this.polygons = data.polygons; - } if ("trainWindows" in data && data.trainWindows != undefined) { this.trainWindows = data.trainWindows; } @@ -91,18 +71,6 @@ export namespace graphicData { get has_canvas() { return pb_1.Message.getField(this, 1) != null; } - get links() { - return pb_1.Message.getRepeatedWrapperField(this, Link, 2) as Link[]; - } - set links(value: Link[]) { - pb_1.Message.setRepeatedWrapperField(this, 2, value); - } - get iscsFans() { - return pb_1.Message.getRepeatedWrapperField(this, IscsFan, 3) as IscsFan[]; - } - set iscsFans(value: IscsFan[]) { - pb_1.Message.setRepeatedWrapperField(this, 3, value); - } get Platforms() { return pb_1.Message.getRepeatedWrapperField(this, Platform, 4) as Platform[]; } @@ -115,18 +83,6 @@ export namespace graphicData { set stations(value: Station[]) { pb_1.Message.setRepeatedWrapperField(this, 5, value); } - get rects() { - return pb_1.Message.getRepeatedWrapperField(this, Rect, 6) as Rect[]; - } - set rects(value: Rect[]) { - pb_1.Message.setRepeatedWrapperField(this, 6, value); - } - get train() { - return pb_1.Message.getRepeatedWrapperField(this, Train, 7) as Train[]; - } - set train(value: Train[]) { - pb_1.Message.setRepeatedWrapperField(this, 7, value); - } get signals() { return pb_1.Message.getRepeatedWrapperField(this, Signal, 8) as Signal[]; } @@ -145,12 +101,6 @@ export namespace graphicData { set section(value: Section[]) { pb_1.Message.setRepeatedWrapperField(this, 10, value); } - get polygons() { - return pb_1.Message.getRepeatedWrapperField(this, Polygon, 11) as Polygon[]; - } - set polygons(value: Polygon[]) { - pb_1.Message.setRepeatedWrapperField(this, 11, value); - } get trainWindows() { return pb_1.Message.getRepeatedWrapperField(this, TrainWindow, 12) as TrainWindow[]; } @@ -189,16 +139,11 @@ export namespace graphicData { } static fromObject(data: { canvas?: ReturnType; - links?: ReturnType[]; - iscsFans?: ReturnType[]; Platforms?: ReturnType[]; stations?: ReturnType[]; - rects?: ReturnType[]; - train?: ReturnType[]; signals?: ReturnType[]; turnouts?: ReturnType[]; section?: ReturnType[]; - polygons?: ReturnType[]; trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; separators?: ReturnType[]; @@ -210,24 +155,12 @@ export namespace graphicData { if (data.canvas != null) { message.canvas = Canvas.fromObject(data.canvas); } - if (data.links != null) { - message.links = data.links.map(item => Link.fromObject(item)); - } - if (data.iscsFans != null) { - message.iscsFans = data.iscsFans.map(item => IscsFan.fromObject(item)); - } if (data.Platforms != null) { message.Platforms = data.Platforms.map(item => Platform.fromObject(item)); } if (data.stations != null) { message.stations = data.stations.map(item => Station.fromObject(item)); } - if (data.rects != null) { - message.rects = data.rects.map(item => Rect.fromObject(item)); - } - if (data.train != null) { - message.train = data.train.map(item => Train.fromObject(item)); - } if (data.signals != null) { message.signals = data.signals.map(item => Signal.fromObject(item)); } @@ -237,9 +170,6 @@ export namespace graphicData { if (data.section != null) { message.section = data.section.map(item => Section.fromObject(item)); } - if (data.polygons != null) { - message.polygons = data.polygons.map(item => Polygon.fromObject(item)); - } if (data.trainWindows != null) { message.trainWindows = data.trainWindows.map(item => TrainWindow.fromObject(item)); } @@ -263,16 +193,11 @@ export namespace graphicData { toObject() { const data: { canvas?: ReturnType; - links?: ReturnType[]; - iscsFans?: ReturnType[]; Platforms?: ReturnType[]; stations?: ReturnType[]; - rects?: ReturnType[]; - train?: ReturnType[]; signals?: ReturnType[]; turnouts?: ReturnType[]; section?: ReturnType[]; - polygons?: ReturnType[]; trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; separators?: ReturnType[]; @@ -283,24 +208,12 @@ export namespace graphicData { if (this.canvas != null) { data.canvas = this.canvas.toObject(); } - if (this.links != null) { - data.links = this.links.map((item: Link) => item.toObject()); - } - if (this.iscsFans != null) { - data.iscsFans = this.iscsFans.map((item: IscsFan) => item.toObject()); - } if (this.Platforms != null) { data.Platforms = this.Platforms.map((item: Platform) => item.toObject()); } if (this.stations != null) { data.stations = this.stations.map((item: Station) => item.toObject()); } - if (this.rects != null) { - data.rects = this.rects.map((item: Rect) => item.toObject()); - } - if (this.train != null) { - data.train = this.train.map((item: Train) => item.toObject()); - } if (this.signals != null) { data.signals = this.signals.map((item: Signal) => item.toObject()); } @@ -310,9 +223,6 @@ export namespace graphicData { if (this.section != null) { data.section = this.section.map((item: Section) => item.toObject()); } - if (this.polygons != null) { - data.polygons = this.polygons.map((item: Polygon) => item.toObject()); - } if (this.trainWindows != null) { data.trainWindows = this.trainWindows.map((item: TrainWindow) => item.toObject()); } @@ -339,26 +249,16 @@ export namespace graphicData { const writer = w || new pb_1.BinaryWriter(); if (this.has_canvas) writer.writeMessage(1, this.canvas, () => this.canvas.serialize(writer)); - if (this.links.length) - writer.writeRepeatedMessage(2, this.links, (item: Link) => item.serialize(writer)); - if (this.iscsFans.length) - writer.writeRepeatedMessage(3, this.iscsFans, (item: IscsFan) => item.serialize(writer)); if (this.Platforms.length) writer.writeRepeatedMessage(4, this.Platforms, (item: Platform) => item.serialize(writer)); if (this.stations.length) writer.writeRepeatedMessage(5, this.stations, (item: Station) => item.serialize(writer)); - if (this.rects.length) - writer.writeRepeatedMessage(6, this.rects, (item: Rect) => item.serialize(writer)); - if (this.train.length) - writer.writeRepeatedMessage(7, this.train, (item: Train) => item.serialize(writer)); if (this.signals.length) writer.writeRepeatedMessage(8, this.signals, (item: Signal) => item.serialize(writer)); if (this.turnouts.length) writer.writeRepeatedMessage(9, this.turnouts, (item: Turnout) => item.serialize(writer)); if (this.section.length) writer.writeRepeatedMessage(10, this.section, (item: Section) => item.serialize(writer)); - if (this.polygons.length) - writer.writeRepeatedMessage(11, this.polygons, (item: Polygon) => item.serialize(writer)); if (this.trainWindows.length) writer.writeRepeatedMessage(12, this.trainWindows, (item: TrainWindow) => item.serialize(writer)); if (this.axleCountings.length) @@ -383,24 +283,12 @@ export namespace graphicData { case 1: reader.readMessage(message.canvas, () => message.canvas = Canvas.deserialize(reader)); break; - case 2: - reader.readMessage(message.links, () => pb_1.Message.addToRepeatedWrapperField(message, 2, Link.deserialize(reader), Link)); - break; - case 3: - reader.readMessage(message.iscsFans, () => pb_1.Message.addToRepeatedWrapperField(message, 3, IscsFan.deserialize(reader), IscsFan)); - break; case 4: reader.readMessage(message.Platforms, () => pb_1.Message.addToRepeatedWrapperField(message, 4, Platform.deserialize(reader), Platform)); break; case 5: reader.readMessage(message.stations, () => pb_1.Message.addToRepeatedWrapperField(message, 5, Station.deserialize(reader), Station)); break; - case 6: - reader.readMessage(message.rects, () => pb_1.Message.addToRepeatedWrapperField(message, 6, Rect.deserialize(reader), Rect)); - break; - case 7: - reader.readMessage(message.train, () => pb_1.Message.addToRepeatedWrapperField(message, 7, Train.deserialize(reader), Train)); - break; case 8: reader.readMessage(message.signals, () => pb_1.Message.addToRepeatedWrapperField(message, 8, Signal.deserialize(reader), Signal)); break; @@ -410,9 +298,6 @@ export namespace graphicData { case 10: reader.readMessage(message.section, () => pb_1.Message.addToRepeatedWrapperField(message, 10, Section.deserialize(reader), Section)); break; - case 11: - reader.readMessage(message.polygons, () => pb_1.Message.addToRepeatedWrapperField(message, 11, Polygon.deserialize(reader), Polygon)); - break; case 12: reader.readMessage(message.trainWindows, () => pb_1.Message.addToRepeatedWrapperField(message, 12, TrainWindow.deserialize(reader), TrainWindow)); break; @@ -1049,610 +934,6 @@ export namespace graphicData { return CommonInfo.deserialize(bytes); } } - export class Link extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - common?: CommonInfo; - code?: string; - curve?: boolean; - segmentsCount?: number; - lineWidth?: number; - lineColor?: string; - points?: Point[]; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [7], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("common" in data && data.common != undefined) { - this.common = data.common; - } - if ("code" in data && data.code != undefined) { - this.code = data.code; - } - if ("curve" in data && data.curve != undefined) { - this.curve = data.curve; - } - if ("segmentsCount" in data && data.segmentsCount != undefined) { - this.segmentsCount = data.segmentsCount; - } - if ("lineWidth" in data && data.lineWidth != undefined) { - this.lineWidth = data.lineWidth; - } - if ("lineColor" in data && data.lineColor != undefined) { - this.lineColor = data.lineColor; - } - if ("points" in data && data.points != undefined) { - this.points = data.points; - } - } - } - get common() { - return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; - } - set common(value: CommonInfo) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_common() { - return pb_1.Message.getField(this, 1) != null; - } - get code() { - return pb_1.Message.getFieldWithDefault(this, 2, "") as string; - } - set code(value: string) { - pb_1.Message.setField(this, 2, value); - } - get curve() { - return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean; - } - set curve(value: boolean) { - pb_1.Message.setField(this, 3, value); - } - get segmentsCount() { - return pb_1.Message.getFieldWithDefault(this, 4, 0) as number; - } - set segmentsCount(value: number) { - pb_1.Message.setField(this, 4, value); - } - get lineWidth() { - return pb_1.Message.getFieldWithDefault(this, 5, 0) as number; - } - set lineWidth(value: number) { - pb_1.Message.setField(this, 5, value); - } - get lineColor() { - return pb_1.Message.getFieldWithDefault(this, 6, "") as string; - } - set lineColor(value: string) { - pb_1.Message.setField(this, 6, value); - } - get points() { - return pb_1.Message.getRepeatedWrapperField(this, Point, 7) as Point[]; - } - set points(value: Point[]) { - pb_1.Message.setRepeatedWrapperField(this, 7, value); - } - static fromObject(data: { - common?: ReturnType; - code?: string; - curve?: boolean; - segmentsCount?: number; - lineWidth?: number; - lineColor?: string; - points?: ReturnType[]; - }): Link { - const message = new Link({}); - if (data.common != null) { - message.common = CommonInfo.fromObject(data.common); - } - if (data.code != null) { - message.code = data.code; - } - if (data.curve != null) { - message.curve = data.curve; - } - if (data.segmentsCount != null) { - message.segmentsCount = data.segmentsCount; - } - if (data.lineWidth != null) { - message.lineWidth = data.lineWidth; - } - if (data.lineColor != null) { - message.lineColor = data.lineColor; - } - if (data.points != null) { - message.points = data.points.map(item => Point.fromObject(item)); - } - return message; - } - toObject() { - const data: { - common?: ReturnType; - code?: string; - curve?: boolean; - segmentsCount?: number; - lineWidth?: number; - lineColor?: string; - points?: ReturnType[]; - } = {}; - if (this.common != null) { - data.common = this.common.toObject(); - } - if (this.code != null) { - data.code = this.code; - } - if (this.curve != null) { - data.curve = this.curve; - } - if (this.segmentsCount != null) { - data.segmentsCount = this.segmentsCount; - } - if (this.lineWidth != null) { - data.lineWidth = this.lineWidth; - } - if (this.lineColor != null) { - data.lineColor = this.lineColor; - } - if (this.points != null) { - data.points = this.points.map((item: Point) => item.toObject()); - } - 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.has_common) - writer.writeMessage(1, this.common, () => this.common.serialize(writer)); - if (this.code.length) - writer.writeString(2, this.code); - if (this.curve != false) - writer.writeBool(3, this.curve); - if (this.segmentsCount != 0) - writer.writeInt32(4, this.segmentsCount); - if (this.lineWidth != 0) - writer.writeInt32(5, this.lineWidth); - if (this.lineColor.length) - writer.writeString(6, this.lineColor); - if (this.points.length) - writer.writeRepeatedMessage(7, this.points, (item: Point) => item.serialize(writer)); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Link { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Link(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); - break; - case 2: - message.code = reader.readString(); - break; - case 3: - message.curve = reader.readBool(); - break; - case 4: - message.segmentsCount = reader.readInt32(); - break; - case 5: - message.lineWidth = reader.readInt32(); - break; - case 6: - message.lineColor = reader.readString(); - break; - case 7: - reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 7, Point.deserialize(reader), Point)); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): Link { - return Link.deserialize(bytes); - } - } - export class Rect extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - common?: CommonInfo; - code?: string; - lineWidth?: number; - lineColor?: string; - width?: number; - height?: number; - radius?: number; - point?: Point; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("common" in data && data.common != undefined) { - this.common = data.common; - } - if ("code" in data && data.code != undefined) { - this.code = data.code; - } - if ("lineWidth" in data && data.lineWidth != undefined) { - this.lineWidth = data.lineWidth; - } - if ("lineColor" in data && data.lineColor != undefined) { - this.lineColor = data.lineColor; - } - if ("width" in data && data.width != undefined) { - this.width = data.width; - } - if ("height" in data && data.height != undefined) { - this.height = data.height; - } - if ("radius" in data && data.radius != undefined) { - this.radius = data.radius; - } - if ("point" in data && data.point != undefined) { - this.point = data.point; - } - } - } - get common() { - return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; - } - set common(value: CommonInfo) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_common() { - return pb_1.Message.getField(this, 1) != null; - } - get code() { - return pb_1.Message.getFieldWithDefault(this, 2, "") as string; - } - set code(value: string) { - pb_1.Message.setField(this, 2, value); - } - get lineWidth() { - return pb_1.Message.getFieldWithDefault(this, 3, 0) as number; - } - set lineWidth(value: number) { - pb_1.Message.setField(this, 3, value); - } - get lineColor() { - return pb_1.Message.getFieldWithDefault(this, 4, "") as string; - } - set lineColor(value: string) { - pb_1.Message.setField(this, 4, value); - } - get width() { - return pb_1.Message.getFieldWithDefault(this, 5, 0) as number; - } - set width(value: number) { - pb_1.Message.setField(this, 5, value); - } - get height() { - return pb_1.Message.getFieldWithDefault(this, 6, 0) as number; - } - set height(value: number) { - pb_1.Message.setField(this, 6, value); - } - get radius() { - return pb_1.Message.getFieldWithDefault(this, 7, 0) as number; - } - set radius(value: number) { - pb_1.Message.setField(this, 7, value); - } - get point() { - return pb_1.Message.getWrapperField(this, Point, 8) as Point; - } - set point(value: Point) { - pb_1.Message.setWrapperField(this, 8, value); - } - get has_point() { - return pb_1.Message.getField(this, 8) != null; - } - static fromObject(data: { - common?: ReturnType; - code?: string; - lineWidth?: number; - lineColor?: string; - width?: number; - height?: number; - radius?: number; - point?: ReturnType; - }): Rect { - const message = new Rect({}); - if (data.common != null) { - message.common = CommonInfo.fromObject(data.common); - } - if (data.code != null) { - message.code = data.code; - } - if (data.lineWidth != null) { - message.lineWidth = data.lineWidth; - } - if (data.lineColor != null) { - message.lineColor = data.lineColor; - } - if (data.width != null) { - message.width = data.width; - } - if (data.height != null) { - message.height = data.height; - } - if (data.radius != null) { - message.radius = data.radius; - } - if (data.point != null) { - message.point = Point.fromObject(data.point); - } - return message; - } - toObject() { - const data: { - common?: ReturnType; - code?: string; - lineWidth?: number; - lineColor?: string; - width?: number; - height?: number; - radius?: number; - point?: ReturnType; - } = {}; - if (this.common != null) { - data.common = this.common.toObject(); - } - if (this.code != null) { - data.code = this.code; - } - if (this.lineWidth != null) { - data.lineWidth = this.lineWidth; - } - if (this.lineColor != null) { - data.lineColor = this.lineColor; - } - if (this.width != null) { - data.width = this.width; - } - if (this.height != null) { - data.height = this.height; - } - if (this.radius != null) { - data.radius = this.radius; - } - if (this.point != null) { - data.point = this.point.toObject(); - } - 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.has_common) - writer.writeMessage(1, this.common, () => this.common.serialize(writer)); - if (this.code.length) - writer.writeString(2, this.code); - if (this.lineWidth != 0) - writer.writeInt32(3, this.lineWidth); - if (this.lineColor.length) - writer.writeString(4, this.lineColor); - if (this.width != 0) - writer.writeFloat(5, this.width); - if (this.height != 0) - writer.writeFloat(6, this.height); - if (this.radius != 0) - writer.writeInt32(7, this.radius); - if (this.has_point) - writer.writeMessage(8, this.point, () => this.point.serialize(writer)); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Rect { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Rect(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); - break; - case 2: - message.code = reader.readString(); - break; - case 3: - message.lineWidth = reader.readInt32(); - break; - case 4: - message.lineColor = reader.readString(); - break; - case 5: - message.width = reader.readFloat(); - break; - case 6: - message.height = reader.readFloat(); - break; - case 7: - message.radius = reader.readInt32(); - break; - case 8: - reader.readMessage(message.point, () => message.point = Point.deserialize(reader)); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): Rect { - return Rect.deserialize(bytes); - } - } - export class Polygon extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - common?: CommonInfo; - code?: string; - lineWidth?: number; - lineColor?: string; - points?: Point[]; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [5], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("common" in data && data.common != undefined) { - this.common = data.common; - } - if ("code" in data && data.code != undefined) { - this.code = data.code; - } - if ("lineWidth" in data && data.lineWidth != undefined) { - this.lineWidth = data.lineWidth; - } - if ("lineColor" in data && data.lineColor != undefined) { - this.lineColor = data.lineColor; - } - if ("points" in data && data.points != undefined) { - this.points = data.points; - } - } - } - get common() { - return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; - } - set common(value: CommonInfo) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_common() { - return pb_1.Message.getField(this, 1) != null; - } - get code() { - return pb_1.Message.getFieldWithDefault(this, 2, "") as string; - } - set code(value: string) { - pb_1.Message.setField(this, 2, value); - } - get lineWidth() { - return pb_1.Message.getFieldWithDefault(this, 3, 0) as number; - } - set lineWidth(value: number) { - pb_1.Message.setField(this, 3, value); - } - get lineColor() { - return pb_1.Message.getFieldWithDefault(this, 4, "") as string; - } - set lineColor(value: string) { - pb_1.Message.setField(this, 4, value); - } - get points() { - return pb_1.Message.getRepeatedWrapperField(this, Point, 5) as Point[]; - } - set points(value: Point[]) { - pb_1.Message.setRepeatedWrapperField(this, 5, value); - } - static fromObject(data: { - common?: ReturnType; - code?: string; - lineWidth?: number; - lineColor?: string; - points?: ReturnType[]; - }): Polygon { - const message = new Polygon({}); - if (data.common != null) { - message.common = CommonInfo.fromObject(data.common); - } - if (data.code != null) { - message.code = data.code; - } - if (data.lineWidth != null) { - message.lineWidth = data.lineWidth; - } - if (data.lineColor != null) { - message.lineColor = data.lineColor; - } - if (data.points != null) { - message.points = data.points.map(item => Point.fromObject(item)); - } - return message; - } - toObject() { - const data: { - common?: ReturnType; - code?: string; - lineWidth?: number; - lineColor?: string; - points?: ReturnType[]; - } = {}; - if (this.common != null) { - data.common = this.common.toObject(); - } - if (this.code != null) { - data.code = this.code; - } - if (this.lineWidth != null) { - data.lineWidth = this.lineWidth; - } - if (this.lineColor != null) { - data.lineColor = this.lineColor; - } - if (this.points != null) { - data.points = this.points.map((item: Point) => item.toObject()); - } - 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.has_common) - writer.writeMessage(1, this.common, () => this.common.serialize(writer)); - if (this.code.length) - writer.writeString(2, this.code); - if (this.lineWidth != 0) - writer.writeInt32(3, this.lineWidth); - if (this.lineColor.length) - writer.writeString(4, this.lineColor); - if (this.points.length) - writer.writeRepeatedMessage(5, this.points, (item: Point) => item.serialize(writer)); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Polygon { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Polygon(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); - break; - case 2: - message.code = reader.readString(); - break; - case 3: - message.lineWidth = reader.readInt32(); - break; - case 4: - message.lineColor = reader.readString(); - break; - case 5: - reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 5, Point.deserialize(reader), Point)); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): Polygon { - return Polygon.deserialize(bytes); - } - } export class Platform extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -2238,192 +1519,6 @@ export namespace graphicData { return AxleCounting.deserialize(bytes); } } - export class Train extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - common?: CommonInfo; - code?: string; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("common" in data && data.common != undefined) { - this.common = data.common; - } - if ("code" in data && data.code != undefined) { - this.code = data.code; - } - } - } - get common() { - return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; - } - set common(value: CommonInfo) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_common() { - return pb_1.Message.getField(this, 1) != null; - } - get code() { - return pb_1.Message.getFieldWithDefault(this, 2, "") as string; - } - set code(value: string) { - pb_1.Message.setField(this, 2, value); - } - static fromObject(data: { - common?: ReturnType; - code?: string; - }): Train { - const message = new Train({}); - if (data.common != null) { - message.common = CommonInfo.fromObject(data.common); - } - if (data.code != null) { - message.code = data.code; - } - return message; - } - toObject() { - const data: { - common?: ReturnType; - code?: string; - } = {}; - if (this.common != null) { - data.common = this.common.toObject(); - } - if (this.code != null) { - data.code = this.code; - } - 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.has_common) - writer.writeMessage(1, this.common, () => this.common.serialize(writer)); - if (this.code.length) - writer.writeString(2, this.code); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Train { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Train(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); - break; - case 2: - message.code = reader.readString(); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): Train { - return Train.deserialize(bytes); - } - } - export class IscsFan extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - common?: CommonInfo; - code?: string; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("common" in data && data.common != undefined) { - this.common = data.common; - } - if ("code" in data && data.code != undefined) { - this.code = data.code; - } - } - } - get common() { - return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; - } - set common(value: CommonInfo) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_common() { - return pb_1.Message.getField(this, 1) != null; - } - get code() { - return pb_1.Message.getFieldWithDefault(this, 2, "") as string; - } - set code(value: string) { - pb_1.Message.setField(this, 2, value); - } - static fromObject(data: { - common?: ReturnType; - code?: string; - }): IscsFan { - const message = new IscsFan({}); - if (data.common != null) { - message.common = CommonInfo.fromObject(data.common); - } - if (data.code != null) { - message.code = data.code; - } - return message; - } - toObject() { - const data: { - common?: ReturnType; - code?: string; - } = {}; - if (this.common != null) { - data.common = this.common.toObject(); - } - if (this.code != null) { - data.code = this.code; - } - 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.has_common) - writer.writeMessage(1, this.common, () => this.common.serialize(writer)); - if (this.code.length) - writer.writeString(2, this.code); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): IscsFan { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new IscsFan(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); - break; - case 2: - message.code = reader.readString(); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): IscsFan { - return IscsFan.deserialize(bytes); - } - } export class Turnout extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { From e02581b1de4eed087408fbeab83c453708fb4409 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Fri, 14 Jul 2023 14:20:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4proto=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drawApp/graphics/TrainInteraction.ts | 38 +------------- src/drawApp/index.ts | 30 ++--------- src/drawApp/lineApp.ts | 67 ++++++++++++++++++------ src/graphics/train/Train.ts | 4 +- 4 files changed, 59 insertions(+), 80 deletions(-) diff --git a/src/drawApp/graphics/TrainInteraction.ts b/src/drawApp/graphics/TrainInteraction.ts index 687e8bc..a76ec3e 100644 --- a/src/drawApp/graphics/TrainInteraction.ts +++ b/src/drawApp/graphics/TrainInteraction.ts @@ -1,7 +1,6 @@ import * as pb_1 from 'google-protobuf'; -import { ITrainData, ITrainState, Train } from 'src/graphics/train/Train'; -import { graphicData } from 'src/protos/stationLayoutGraphics'; -import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase'; +import { ITrainState, Train } from 'src/graphics/train/Train'; +import { GraphicStateBase } from './GraphicDataBase'; import { state } from 'src/protos/device_status'; import { train } from 'src/protos/train'; import { MenuItemOptions } from 'src/jl-graphic/ui/Menu'; @@ -13,39 +12,6 @@ import { } from 'src/jl-graphic'; import { DisplayObject, FederatedMouseEvent } from 'pixi.js'; -export class TrainData extends GraphicDataBase implements ITrainData { - constructor(data?: graphicData.Train) { - let train; - if (!data) { - train = new graphicData.Train({ - common: GraphicDataBase.defaultCommonInfo(Train.Type), - }); - } else { - train = data; - } - super(train); - } - - public get data(): graphicData.Train { - return this.getData(); - } - get code(): string { - return this.data.code; - } - set code(v: string) { - this.data.code = v; - } - clone(): TrainData { - return new TrainData(this.data.cloneMessage()); - } - copyFrom(data: TrainData): void { - pb_1.Message.copyInto(data.data, this.data); - } - eq(other: TrainData): boolean { - return pb_1.Message.equals(this.data, other.data); - } -} - export class TrainState extends GraphicStateBase implements ITrainState { constructor(proto?: train.TrainInfo) { let states; diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 32ba6a1..9514ae4 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -1,6 +1,5 @@ import { fromUint8Array, toUint8Array } from 'js-base64'; -import { Link } from 'src/graphics/link/Link'; -import { Train, TrainTemplate } from 'src/graphics/train/Train'; +import { TrainTemplate } from 'src/graphics/train/Train'; import { TrainDraw } from 'src/graphics/train/TrainDrawAssistant'; import { Signal, SignalTemplate } from 'src/graphics/signal/Signal'; import { SignalDraw } from 'src/graphics/signal/SignalDrawAssistant'; @@ -14,17 +13,14 @@ import { } from 'src/jl-graphic'; import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; import { MenuItemOptions } from 'src/jl-graphic/ui/Menu'; -import { LinkData } from './graphics/LinkInteraction'; -import { TrainData, TrainState } from './graphics/TrainInteraction'; +import { TrainState } from './graphics/TrainInteraction'; import { SignalData, DrawSignalInteraction, SignalState, } from './graphics/SignalInteraction'; import { graphicData } from 'src/protos/stationLayoutGraphics'; -import { Rect } from 'src/graphics/rect/Rect'; import { RectDraw } from 'src/graphics/rect/RectDrawAssistant'; -import { RectData } from './graphics/RectInteraction'; import { Platform, PlatformTemplate } from 'src/graphics/platform/Platform'; import { PlatformData, PlatformState } from './graphics/PlatformInteraction'; import { PlatformDraw } from 'src/graphics/platform/PlatformDrawAssistant'; @@ -210,7 +206,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { app, new SignalTemplate(new SignalData(), new SignalState()) ), - new TrainDraw(app, new TrainTemplate(new TrainData(), new TrainState())), + new TrainDraw(app, new TrainTemplate(new TrainState())), new SectionDraw(app, new SectionTemplate(new SectionData())), new TurnoutDraw( app, @@ -350,21 +346,12 @@ export function saveDrawDatas(app: JlDrawApp) { }); const graphics = app.queryStore.getAllGraphics(); graphics.forEach((g) => { - if (Link.Type === g.type) { - const linkData = (g as Link).saveData(); - storage.links.push((linkData as LinkData).data); - } else if (Rect.Type === g.type) { - const rectData = (g as Rect).saveData(); - storage.rects.push((rectData as RectData).data); - } else if (Platform.Type === g.type) { + if (Platform.Type === g.type) { const platformData = (g as Platform).saveData(); storage.Platforms.push((platformData as PlatformData).data); } else if (Station.Type === g.type) { const stationData = (g as Station).saveData(); storage.stations.push((stationData as StationData).data); - } else if (Train.Type === g.type) { - const trainData = (g as Train).saveData(); - storage.train.push((trainData as TrainData).data); } else if (Turnout.Type === g.type) { const turnoutData = (g as Turnout).saveData(); storage.turnouts.push((turnoutData as TurnoutData).data); @@ -418,21 +405,12 @@ export async function loadDrawDatas(app: GraphicApp) { ); app.updateCanvas(storage.canvas); const datas: GraphicData[] = []; - storage.links.forEach((link) => { - datas.push(new LinkData(link)); - }); - storage.rects.forEach((rect) => { - datas.push(new RectData(rect)); - }); storage.Platforms.forEach((platform) => { datas.push(new PlatformData(platform)); }); storage.stations.forEach((station) => { datas.push(new StationData(station)); }); - storage.train.forEach((train) => { - datas.push(new TrainData(train)); - }); storage.turnouts.forEach((turnout) => { datas.push(new TurnoutData(turnout)); }); diff --git a/src/drawApp/lineApp.ts b/src/drawApp/lineApp.ts index 3ecfa47..17692bd 100644 --- a/src/drawApp/lineApp.ts +++ b/src/drawApp/lineApp.ts @@ -5,7 +5,7 @@ import { AppWsMsgBroker, GraphicState, } from 'src/jl-graphic'; -import { TrainData, TrainState } from './graphics/TrainInteraction'; +import { TrainState } from './graphics/TrainInteraction'; import { TrainTemplate } from 'src/graphics/train/Train'; import { SignalData, @@ -35,7 +35,7 @@ import { useLineStore } from 'src/stores/line-store'; import { toUint8Array } from 'js-base64'; import { getWebsocketUrl } from 'src/configs/UrlManage'; import { getJwtToken } from 'src/configs/TokenManage'; -import { state } from 'src/protos/ws_message'; +import { state } from 'src/protos/device_state'; import { AxleCounting, AxleCountingTemplate, @@ -68,7 +68,7 @@ export function destroyLineApp(): void { export function initLineApp(dom: HTMLElement): GraphicApp { lineApp = new GraphicApp(dom); const graphicTemplate = [ - new TrainTemplate(new TrainData(), new TrainState()), + new TrainTemplate(new TrainState()), new SignalTemplate(new SignalData(), new SignalState()), new PlatformTemplate(new PlatformData(), new PlatformState()), new StationTemplate(new StationData(), new StationState()), @@ -124,9 +124,6 @@ export async function loadLineDatas(app: GraphicApp) { storage.stations.forEach((station) => { datas.push(new StationData(station)); }); - storage.train.forEach((train) => { - datas.push(new TrainData(train)); - }); storage.turnouts.forEach((turnout) => { datas.push(new TurnoutData(turnout)); }); @@ -167,16 +164,54 @@ export async function loadLineDatas(app: GraphicApp) { msgBroker.subscribe({ destination: `/simulation/${simulationId}/devices/status`, messageConverter: (message: Uint8Array) => { - const storage = state.WsLineMessage.deserialize(message); - storage.signal.forEach((item) => { - states.push(new SignalState(item)); - }); - storage.platform.forEach((item) => { - states.push(new PlatformState(item)); - }); - storage.rtu.forEach((item) => { - states.push(new StationState(item)); - }); + const storage = state.PushedDevicesStatus.deserialize(message); + if (storage.all) { + storage.allStatus.sectionState.forEach((item) => { + if (state.SectionType[item.type] == 'Axle') { + //计轴区段 + // states.push(new AxleCountingState(item)); + } else if (state.SectionType[item.type] == 'Logic') { + // 逻辑区段 + // states.push(new LogicSectionState(item)); + } else if (state.SectionType[item.type] == 'Physic') { + // 物理区段 + // states.push(new SectionState(item)); + } + }); + storage.allStatus.switchState.forEach((item) => { + // 道岔 + // states.push(new TurnoutState(item)); + }); + storage.allStatus.trainState.forEach((item) => { + // 列车 + // states.push(new TrainState(item)); + }); + } else { + storage.varStatus.updatedSection.forEach((item) => { + if (state.SectionType[item.type] == 'Axle') { + //计轴区段 + // states.push(new AxleCountingState(item)); + } else if (state.SectionType[item.type] == 'Logic') { + // 逻辑区段 + // states.push(new LogicSectionState(item)); + } else if (state.SectionType[item.type] == 'Physic') { + // 物理区段 + // states.push(new SectionState(item)); + } + }); + storage.varStatus.updatedSwitch.forEach((item) => { + // 道岔 + // states.push(new TurnoutState(item)); + }); + storage.varStatus.updatedTrain.forEach((item) => { + // 列车 + // states.push(new TrainState(item)); + }); + storage.varStatus.removedTrainId.forEach((item) => { + // 移除列车 + // states.push(new TrainState(item)); + }); + } return states; }, }); diff --git a/src/graphics/train/Train.ts b/src/graphics/train/Train.ts index d432abf..71a511a 100644 --- a/src/graphics/train/Train.ts +++ b/src/graphics/train/Train.ts @@ -412,8 +412,8 @@ export class Train extends JlGraphic { } export class TrainTemplate extends JlGraphicTemplate { - constructor(dataTemplate: ITrainData, stateTemplate: ITrainState) { - super(Train.Type, { dataTemplate, stateTemplate }); + constructor(stateTemplate: ITrainState) { + super(Train.Type, { stateTemplate }); } new(): Train { const train = new Train();