From 10a2c9de278b166d2b218cf7b5978c474f02dd0f Mon Sep 17 00:00:00 2001 From: Yuan Date: Thu, 29 Jun 2023 17:33:19 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=9B=9B=E9=81=93=E5=B2=94=E5=85=B1?= =?UTF-8?q?=E7=82=B9=E5=85=B3=E7=B3=BB=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/turnout/Turnout.ts | 42 ++++-- src/protos/device_info.ts | 155 ++++++++++---------- src/protos/stationLayoutGraphics.ts | 213 +++++++++++++++++++++++----- src/protos/ws_message.ts | 16 +-- xian-ncc-da-message | 2 +- 5 files changed, 291 insertions(+), 137 deletions(-) diff --git a/src/graphics/turnout/Turnout.ts b/src/graphics/turnout/Turnout.ts index df906e7..3db11c3 100644 --- a/src/graphics/turnout/Turnout.ts +++ b/src/graphics/turnout/Turnout.ts @@ -6,6 +6,7 @@ import { JlGraphic, JlGraphicTemplate, VectorText, + angleOfIncludedAngle, distance2, } from 'src/jl-graphic'; import { Section, SectionPort } from '../section/Section'; @@ -208,9 +209,11 @@ export class Turnout extends JlGraphic { }); /** 道岔和道岔 */ - this.queryStore.queryByType(Turnout.Type).forEach((turnout) => { - if (turnout.id === this.id) return; - this.getPortPoints().forEach((thisPort, i) => { + this.getPortPoints().forEach((thisPort, i) => { + let params: GraphicRelationParam[] = [], + deflection = 180; + this.queryStore.queryByType(Turnout.Type).forEach((turnout) => { + if (turnout.id === this.id) return; turnout.getPortPoints().forEach((otherPort, j) => { if ( distance2( @@ -218,19 +221,34 @@ export class Turnout extends JlGraphic { turnout.localToCanvasPoint(otherPort[otherPort.length - 1]) ) <= epsilon ) { - this.relationManage.addRelation( - new GraphicRelationParam( - this, - [TurnoutPort.A, TurnoutPort.B, TurnoutPort.C][i] - ), - new GraphicRelationParam( - turnout, - [TurnoutPort.A, TurnoutPort.B, TurnoutPort.C][j] - ) + const angle = angleOfIncludedAngle( + this.localToCanvasPoint(thisPort[thisPort.length - 1]) /* 交点 */, + thisPort[thisPort.length - 2] + ? this.localToCanvasPoint(thisPort[thisPort.length - 2]) + : this.position, + otherPort[otherPort.length - 2] + ? turnout.localToCanvasPoint(otherPort[otherPort.length - 2]) + : turnout.position ); + if (180 - Math.abs(angle) <= deflection) { + deflection = 180 - Math.abs(angle); + params = [ + new GraphicRelationParam( + this, + [TurnoutPort.A, TurnoutPort.B, TurnoutPort.C][i] + ), + new GraphicRelationParam( + turnout, + [TurnoutPort.A, TurnoutPort.B, TurnoutPort.C][j] + ), + ]; + } } }); }); + if (params.length === 2) { + this.relationManage.addRelation(params[0], params[1]); + } }); } diff --git a/src/protos/device_info.ts b/src/protos/device_info.ts index 208ffea..fd8491b 100644 --- a/src/protos/device_info.ts +++ b/src/protos/device_info.ts @@ -12,11 +12,12 @@ export namespace state { id?: string; code?: string; type?: dependency_1.graphicData.Section.SectionType; - kilometerCode?: string[]; + kilometerSystem?: dependency_1.graphicData.KilometerSystem[]; children?: Section[]; + convertKilometer?: number[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5, 6], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("id" in data && data.id != undefined) { this.id = data.id; @@ -27,12 +28,15 @@ export namespace state { if ("type" in data && data.type != undefined) { this.type = data.type; } - if ("kilometerCode" in data && data.kilometerCode != undefined) { - this.kilometerCode = data.kilometerCode; + if ("kilometerSystem" in data && data.kilometerSystem != undefined) { + this.kilometerSystem = data.kilometerSystem; } if ("children" in data && data.children != undefined) { this.children = data.children; } + if ("convertKilometer" in data && data.convertKilometer != undefined) { + this.convertKilometer = data.convertKilometer; + } } } get id() { @@ -53,11 +57,11 @@ export namespace state { set type(value: dependency_1.graphicData.Section.SectionType) { pb_1.Message.setField(this, 3, value); } - get kilometerCode() { - return pb_1.Message.getFieldWithDefault(this, 4, []) as string[]; + get kilometerSystem() { + return pb_1.Message.getRepeatedWrapperField(this, dependency_1.graphicData.KilometerSystem, 4) as dependency_1.graphicData.KilometerSystem[]; } - set kilometerCode(value: string[]) { - pb_1.Message.setField(this, 4, value); + set kilometerSystem(value: dependency_1.graphicData.KilometerSystem[]) { + pb_1.Message.setRepeatedWrapperField(this, 4, value); } get children() { return pb_1.Message.getRepeatedWrapperField(this, Section, 5) as Section[]; @@ -65,12 +69,19 @@ export namespace state { set children(value: Section[]) { pb_1.Message.setRepeatedWrapperField(this, 5, value); } + get convertKilometer() { + return pb_1.Message.getFieldWithDefault(this, 6, []) as number[]; + } + set convertKilometer(value: number[]) { + pb_1.Message.setField(this, 6, value); + } static fromObject(data: { id?: string; code?: string; type?: dependency_1.graphicData.Section.SectionType; - kilometerCode?: string[]; + kilometerSystem?: ReturnType[]; children?: ReturnType[]; + convertKilometer?: number[]; }): Section { const message = new Section({}); if (data.id != null) { @@ -82,12 +93,15 @@ export namespace state { if (data.type != null) { message.type = data.type; } - if (data.kilometerCode != null) { - message.kilometerCode = data.kilometerCode; + if (data.kilometerSystem != null) { + message.kilometerSystem = data.kilometerSystem.map(item => dependency_1.graphicData.KilometerSystem.fromObject(item)); } if (data.children != null) { message.children = data.children.map(item => Section.fromObject(item)); } + if (data.convertKilometer != null) { + message.convertKilometer = data.convertKilometer; + } return message; } toObject() { @@ -95,8 +109,9 @@ export namespace state { id?: string; code?: string; type?: dependency_1.graphicData.Section.SectionType; - kilometerCode?: string[]; + kilometerSystem?: ReturnType[]; children?: ReturnType[]; + convertKilometer?: number[]; } = {}; if (this.id != null) { data.id = this.id; @@ -107,12 +122,15 @@ export namespace state { if (this.type != null) { data.type = this.type; } - if (this.kilometerCode != null) { - data.kilometerCode = this.kilometerCode; + if (this.kilometerSystem != null) { + data.kilometerSystem = this.kilometerSystem.map((item: dependency_1.graphicData.KilometerSystem) => item.toObject()); } if (this.children != null) { data.children = this.children.map((item: Section) => item.toObject()); } + if (this.convertKilometer != null) { + data.convertKilometer = this.convertKilometer; + } return data; } serialize(): Uint8Array; @@ -125,10 +143,12 @@ export namespace state { writer.writeString(2, this.code); if (this.type != dependency_1.graphicData.Section.SectionType.Physical) writer.writeEnum(3, this.type); - if (this.kilometerCode.length) - writer.writeRepeatedString(4, this.kilometerCode); + if (this.kilometerSystem.length) + writer.writeRepeatedMessage(4, this.kilometerSystem, (item: dependency_1.graphicData.KilometerSystem) => item.serialize(writer)); if (this.children.length) writer.writeRepeatedMessage(5, this.children, (item: Section) => item.serialize(writer)); + if (this.convertKilometer.length) + writer.writePackedInt64(6, this.convertKilometer); if (!w) return writer.getResultBuffer(); } @@ -148,11 +168,14 @@ export namespace state { message.type = reader.readEnum(); break; case 4: - pb_1.Message.addToRepeatedField(message, 4, reader.readString()); + reader.readMessage(message.kilometerSystem, () => pb_1.Message.addToRepeatedWrapperField(message, 4, dependency_1.graphicData.KilometerSystem.deserialize(reader), dependency_1.graphicData.KilometerSystem)); break; case 5: reader.readMessage(message.children, () => pb_1.Message.addToRepeatedWrapperField(message, 5, Section.deserialize(reader), Section)); break; + case 6: + message.convertKilometer = reader.readPackedInt64(); + break; default: reader.skipField(); } } @@ -170,12 +193,11 @@ export namespace state { constructor(data?: any[] | { id?: string; code?: string; - paSection?: Section; - pbSection?: Section; - pcSection?: Section; + kilometerSystem?: dependency_1.graphicData.KilometerSystem[]; + convertKilometer?: number[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 4], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("id" in data && data.id != undefined) { this.id = data.id; @@ -183,14 +205,11 @@ export namespace state { if ("code" in data && data.code != undefined) { this.code = data.code; } - if ("paSection" in data && data.paSection != undefined) { - this.paSection = data.paSection; + if ("kilometerSystem" in data && data.kilometerSystem != undefined) { + this.kilometerSystem = data.kilometerSystem; } - if ("pbSection" in data && data.pbSection != undefined) { - this.pbSection = data.pbSection; - } - if ("pcSection" in data && data.pcSection != undefined) { - this.pcSection = data.pcSection; + if ("convertKilometer" in data && data.convertKilometer != undefined) { + this.convertKilometer = data.convertKilometer; } } } @@ -206,39 +225,23 @@ export namespace state { set code(value: string) { pb_1.Message.setField(this, 2, value); } - get paSection() { - return pb_1.Message.getWrapperField(this, Section, 3) as Section; + get kilometerSystem() { + return pb_1.Message.getRepeatedWrapperField(this, dependency_1.graphicData.KilometerSystem, 3) as dependency_1.graphicData.KilometerSystem[]; } - set paSection(value: Section) { - pb_1.Message.setWrapperField(this, 3, value); + set kilometerSystem(value: dependency_1.graphicData.KilometerSystem[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); } - get has_paSection() { - return pb_1.Message.getField(this, 3) != null; + get convertKilometer() { + return pb_1.Message.getFieldWithDefault(this, 4, []) as number[]; } - get pbSection() { - return pb_1.Message.getWrapperField(this, Section, 4) as Section; - } - set pbSection(value: Section) { - pb_1.Message.setWrapperField(this, 4, value); - } - get has_pbSection() { - return pb_1.Message.getField(this, 4) != null; - } - get pcSection() { - return pb_1.Message.getWrapperField(this, Section, 5) as Section; - } - set pcSection(value: Section) { - pb_1.Message.setWrapperField(this, 5, value); - } - get has_pcSection() { - return pb_1.Message.getField(this, 5) != null; + set convertKilometer(value: number[]) { + pb_1.Message.setField(this, 4, value); } static fromObject(data: { id?: string; code?: string; - paSection?: ReturnType; - pbSection?: ReturnType; - pcSection?: ReturnType; + kilometerSystem?: ReturnType[]; + convertKilometer?: number[]; }): Switch { const message = new Switch({}); if (data.id != null) { @@ -247,14 +250,11 @@ export namespace state { if (data.code != null) { message.code = data.code; } - if (data.paSection != null) { - message.paSection = Section.fromObject(data.paSection); + if (data.kilometerSystem != null) { + message.kilometerSystem = data.kilometerSystem.map(item => dependency_1.graphicData.KilometerSystem.fromObject(item)); } - if (data.pbSection != null) { - message.pbSection = Section.fromObject(data.pbSection); - } - if (data.pcSection != null) { - message.pcSection = Section.fromObject(data.pcSection); + if (data.convertKilometer != null) { + message.convertKilometer = data.convertKilometer; } return message; } @@ -262,9 +262,8 @@ export namespace state { const data: { id?: string; code?: string; - paSection?: ReturnType; - pbSection?: ReturnType; - pcSection?: ReturnType; + kilometerSystem?: ReturnType[]; + convertKilometer?: number[]; } = {}; if (this.id != null) { data.id = this.id; @@ -272,14 +271,11 @@ export namespace state { if (this.code != null) { data.code = this.code; } - if (this.paSection != null) { - data.paSection = this.paSection.toObject(); + if (this.kilometerSystem != null) { + data.kilometerSystem = this.kilometerSystem.map((item: dependency_1.graphicData.KilometerSystem) => item.toObject()); } - if (this.pbSection != null) { - data.pbSection = this.pbSection.toObject(); - } - if (this.pcSection != null) { - data.pcSection = this.pcSection.toObject(); + if (this.convertKilometer != null) { + data.convertKilometer = this.convertKilometer; } return data; } @@ -291,12 +287,10 @@ export namespace state { writer.writeString(1, this.id); if (this.code.length) writer.writeString(2, this.code); - if (this.has_paSection) - writer.writeMessage(3, this.paSection, () => this.paSection.serialize(writer)); - if (this.has_pbSection) - writer.writeMessage(4, this.pbSection, () => this.pbSection.serialize(writer)); - if (this.has_pcSection) - writer.writeMessage(5, this.pcSection, () => this.pcSection.serialize(writer)); + if (this.kilometerSystem.length) + writer.writeRepeatedMessage(3, this.kilometerSystem, (item: dependency_1.graphicData.KilometerSystem) => item.serialize(writer)); + if (this.convertKilometer.length) + writer.writePackedInt64(4, this.convertKilometer); if (!w) return writer.getResultBuffer(); } @@ -313,13 +307,10 @@ export namespace state { message.code = reader.readString(); break; case 3: - reader.readMessage(message.paSection, () => message.paSection = Section.deserialize(reader)); + reader.readMessage(message.kilometerSystem, () => pb_1.Message.addToRepeatedWrapperField(message, 3, dependency_1.graphicData.KilometerSystem.deserialize(reader), dependency_1.graphicData.KilometerSystem)); break; case 4: - reader.readMessage(message.pbSection, () => message.pbSection = Section.deserialize(reader)); - break; - case 5: - reader.readMessage(message.pcSection, () => message.pcSection = Section.deserialize(reader)); + message.convertKilometer = reader.readPackedInt64(); break; default: reader.skipField(); } diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index e72c60c..7f078f6 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -25,9 +25,10 @@ export namespace graphicData { polygons?: Polygon[]; trainWindows?: TrainWindow[]; axleCountings?: AxleCounting[]; + separators?: Separator[]; }) { 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, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; @@ -80,6 +81,9 @@ export namespace graphicData { if ("axleCountings" in data && data.axleCountings != undefined) { this.axleCountings = data.axleCountings; } + if ("separators" in data && data.separators != undefined) { + this.separators = data.separators; + } } } get canvas() { @@ -187,6 +191,12 @@ export namespace graphicData { set axleCountings(value: AxleCounting[]) { pb_1.Message.setRepeatedWrapperField(this, 17, value); } + get separators() { + return pb_1.Message.getRepeatedWrapperField(this, Separator, 18) as Separator[]; + } + set separators(value: Separator[]) { + pb_1.Message.setRepeatedWrapperField(this, 18, value); + } static fromObject(data: { canvas?: ReturnType; links?: ReturnType[]; @@ -205,6 +215,7 @@ export namespace graphicData { polygons?: ReturnType[]; trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; + separators?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -258,6 +269,9 @@ export namespace graphicData { if (data.axleCountings != null) { message.axleCountings = data.axleCountings.map(item => AxleCounting.fromObject(item)); } + if (data.separators != null) { + message.separators = data.separators.map(item => Separator.fromObject(item)); + } return message; } toObject() { @@ -279,6 +293,7 @@ export namespace graphicData { polygons?: ReturnType[]; trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; + separators?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -331,6 +346,9 @@ export namespace graphicData { if (this.axleCountings != null) { data.axleCountings = this.axleCountings.map((item: AxleCounting) => item.toObject()); } + if (this.separators != null) { + data.separators = this.separators.map((item: Separator) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -371,6 +389,8 @@ export namespace graphicData { writer.writeRepeatedMessage(16, this.trainWindows, (item: TrainWindow) => item.serialize(writer)); if (this.axleCountings.length) writer.writeRepeatedMessage(17, this.axleCountings, (item: AxleCounting) => item.serialize(writer)); + if (this.separators.length) + writer.writeRepeatedMessage(18, this.separators, (item: Separator) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -431,6 +451,9 @@ export namespace graphicData { case 17: reader.readMessage(message.axleCountings, () => pb_1.Message.addToRepeatedWrapperField(message, 17, AxleCounting.deserialize(reader), AxleCounting)); break; + case 18: + reader.readMessage(message.separators, () => pb_1.Message.addToRepeatedWrapperField(message, 18, Separator.deserialize(reader), Separator)); + break; default: reader.skipField(); } } @@ -1799,7 +1822,7 @@ export namespace graphicData { code?: string; hasControl?: boolean; concentrationStations?: boolean; - kilometerCode?: string; + kilometerSystem?: KilometerSystem; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -1816,8 +1839,8 @@ export namespace graphicData { if ("concentrationStations" in data && data.concentrationStations != undefined) { this.concentrationStations = data.concentrationStations; } - if ("kilometerCode" in data && data.kilometerCode != undefined) { - this.kilometerCode = data.kilometerCode; + if ("kilometerSystem" in data && data.kilometerSystem != undefined) { + this.kilometerSystem = data.kilometerSystem; } } } @@ -1848,18 +1871,21 @@ export namespace graphicData { set concentrationStations(value: boolean) { pb_1.Message.setField(this, 4, value); } - get kilometerCode() { - return pb_1.Message.getFieldWithDefault(this, 5, "") as string; + get kilometerSystem() { + return pb_1.Message.getWrapperField(this, KilometerSystem, 6) as KilometerSystem; } - set kilometerCode(value: string) { - pb_1.Message.setField(this, 5, value); + set kilometerSystem(value: KilometerSystem) { + pb_1.Message.setWrapperField(this, 6, value); + } + get has_kilometerSystem() { + return pb_1.Message.getField(this, 6) != null; } static fromObject(data: { common?: ReturnType; code?: string; hasControl?: boolean; concentrationStations?: boolean; - kilometerCode?: string; + kilometerSystem?: ReturnType; }): Station { const message = new Station({}); if (data.common != null) { @@ -1874,8 +1900,8 @@ export namespace graphicData { if (data.concentrationStations != null) { message.concentrationStations = data.concentrationStations; } - if (data.kilometerCode != null) { - message.kilometerCode = data.kilometerCode; + if (data.kilometerSystem != null) { + message.kilometerSystem = KilometerSystem.fromObject(data.kilometerSystem); } return message; } @@ -1885,7 +1911,7 @@ export namespace graphicData { code?: string; hasControl?: boolean; concentrationStations?: boolean; - kilometerCode?: string; + kilometerSystem?: ReturnType; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -1899,8 +1925,8 @@ export namespace graphicData { if (this.concentrationStations != null) { data.concentrationStations = this.concentrationStations; } - if (this.kilometerCode != null) { - data.kilometerCode = this.kilometerCode; + if (this.kilometerSystem != null) { + data.kilometerSystem = this.kilometerSystem.toObject(); } return data; } @@ -1916,8 +1942,8 @@ export namespace graphicData { writer.writeBool(3, this.hasControl); if (this.concentrationStations != false) writer.writeBool(4, this.concentrationStations); - if (this.kilometerCode.length) - writer.writeString(5, this.kilometerCode); + if (this.has_kilometerSystem) + writer.writeMessage(6, this.kilometerSystem, () => this.kilometerSystem.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -1939,8 +1965,8 @@ export namespace graphicData { case 4: message.concentrationStations = reader.readBool(); break; - case 5: - message.kilometerCode = reader.readString(); + case 6: + reader.readMessage(message.kilometerSystem, () => message.kilometerSystem = KilometerSystem.deserialize(reader)); break; default: reader.skipField(); } @@ -2214,7 +2240,7 @@ export namespace graphicData { constructor(data?: any[] | { common?: CommonInfo; code?: string; - kilometerCode?: string; + kilometerSystem?: KilometerSystem; axleCountingRef?: RelatedRef[]; }) { super(); @@ -2226,8 +2252,8 @@ export namespace graphicData { if ("code" in data && data.code != undefined) { this.code = data.code; } - if ("kilometerCode" in data && data.kilometerCode != undefined) { - this.kilometerCode = data.kilometerCode; + if ("kilometerSystem" in data && data.kilometerSystem != undefined) { + this.kilometerSystem = data.kilometerSystem; } if ("axleCountingRef" in data && data.axleCountingRef != undefined) { this.axleCountingRef = data.axleCountingRef; @@ -2249,11 +2275,14 @@ export namespace graphicData { set code(value: string) { pb_1.Message.setField(this, 2, value); } - get kilometerCode() { - return pb_1.Message.getFieldWithDefault(this, 3, "") as string; + get kilometerSystem() { + return pb_1.Message.getWrapperField(this, KilometerSystem, 3) as KilometerSystem; } - set kilometerCode(value: string) { - pb_1.Message.setField(this, 3, value); + set kilometerSystem(value: KilometerSystem) { + pb_1.Message.setWrapperField(this, 3, value); + } + get has_kilometerSystem() { + return pb_1.Message.getField(this, 3) != null; } get axleCountingRef() { return pb_1.Message.getRepeatedWrapperField(this, RelatedRef, 4) as RelatedRef[]; @@ -2264,7 +2293,7 @@ export namespace graphicData { static fromObject(data: { common?: ReturnType; code?: string; - kilometerCode?: string; + kilometerSystem?: ReturnType; axleCountingRef?: ReturnType[]; }): AxleCounting { const message = new AxleCounting({}); @@ -2274,8 +2303,8 @@ export namespace graphicData { if (data.code != null) { message.code = data.code; } - if (data.kilometerCode != null) { - message.kilometerCode = data.kilometerCode; + if (data.kilometerSystem != null) { + message.kilometerSystem = KilometerSystem.fromObject(data.kilometerSystem); } if (data.axleCountingRef != null) { message.axleCountingRef = data.axleCountingRef.map(item => RelatedRef.fromObject(item)); @@ -2286,7 +2315,7 @@ export namespace graphicData { const data: { common?: ReturnType; code?: string; - kilometerCode?: string; + kilometerSystem?: ReturnType; axleCountingRef?: ReturnType[]; } = {}; if (this.common != null) { @@ -2295,8 +2324,8 @@ export namespace graphicData { if (this.code != null) { data.code = this.code; } - if (this.kilometerCode != null) { - data.kilometerCode = this.kilometerCode; + if (this.kilometerSystem != null) { + data.kilometerSystem = this.kilometerSystem.toObject(); } if (this.axleCountingRef != null) { data.axleCountingRef = this.axleCountingRef.map((item: RelatedRef) => item.toObject()); @@ -2311,8 +2340,8 @@ export namespace graphicData { writer.writeMessage(1, this.common, () => this.common.serialize(writer)); if (this.code.length) writer.writeString(2, this.code); - if (this.kilometerCode.length) - writer.writeString(3, this.kilometerCode); + if (this.has_kilometerSystem) + writer.writeMessage(3, this.kilometerSystem, () => this.kilometerSystem.serialize(writer)); if (this.axleCountingRef.length) writer.writeRepeatedMessage(4, this.axleCountingRef, (item: RelatedRef) => item.serialize(writer)); if (!w) @@ -2331,7 +2360,7 @@ export namespace graphicData { message.code = reader.readString(); break; case 3: - message.kilometerCode = reader.readString(); + reader.readMessage(message.kilometerSystem, () => message.kilometerSystem = KilometerSystem.deserialize(reader)); break; case 4: reader.readMessage(message.axleCountingRef, () => pb_1.Message.addToRepeatedWrapperField(message, 4, RelatedRef.deserialize(reader), RelatedRef)); @@ -3955,4 +3984,120 @@ export namespace graphicData { C = 2 } } + export class Separator extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + common?: CommonInfo; + code?: string; + separatorType?: 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; + } + if ("separatorType" in data && data.separatorType != undefined) { + this.separatorType = data.separatorType; + } + } + } + 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 separatorType() { + return pb_1.Message.getFieldWithDefault(this, 3, "") as string; + } + set separatorType(value: string) { + pb_1.Message.setField(this, 3, value); + } + static fromObject(data: { + common?: ReturnType; + code?: string; + separatorType?: string; + }): Separator { + const message = new Separator({}); + if (data.common != null) { + message.common = CommonInfo.fromObject(data.common); + } + if (data.code != null) { + message.code = data.code; + } + if (data.separatorType != null) { + message.separatorType = data.separatorType; + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + separatorType?: string; + } = {}; + if (this.common != null) { + data.common = this.common.toObject(); + } + if (this.code != null) { + data.code = this.code; + } + if (this.separatorType != null) { + data.separatorType = this.separatorType; + } + 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.separatorType.length) + writer.writeString(3, this.separatorType); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Separator { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Separator(); + 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.separatorType = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Separator { + return Separator.deserialize(bytes); + } + } } diff --git a/src/protos/ws_message.ts b/src/protos/ws_message.ts index 99d400c..e23b80d 100644 --- a/src/protos/ws_message.ts +++ b/src/protos/ws_message.ts @@ -469,7 +469,7 @@ export namespace state { groupId?: string; destinationId?: number; show?: boolean; - kilometerCode?: string; + kilometerCode?: number; dir?: number; }) { super(); @@ -529,9 +529,9 @@ export namespace state { pb_1.Message.setField(this, 5, value); } get kilometerCode() { - return pb_1.Message.getFieldWithDefault(this, 6, "") as string; + return pb_1.Message.getFieldWithDefault(this, 6, 0) as number; } - set kilometerCode(value: string) { + set kilometerCode(value: number) { pb_1.Message.setField(this, 6, value); } get dir() { @@ -546,7 +546,7 @@ export namespace state { groupId?: string; destinationId?: number; show?: boolean; - kilometerCode?: string; + kilometerCode?: number; dir?: number; }): WsLineNetTrainOffsetMessage { const message = new WsLineNetTrainOffsetMessage({}); @@ -580,7 +580,7 @@ export namespace state { groupId?: string; destinationId?: number; show?: boolean; - kilometerCode?: string; + kilometerCode?: number; dir?: number; } = {}; if (this.lineId != null) { @@ -620,8 +620,8 @@ export namespace state { writer.writeInt32(4, this.destinationId); if (this.show != false) writer.writeBool(5, this.show); - if (this.kilometerCode.length) - writer.writeString(6, this.kilometerCode); + if (this.kilometerCode != 0) + writer.writeInt64(6, this.kilometerCode); if (this.dir != 0) writer.writeInt32(7, this.dir); if (!w) @@ -649,7 +649,7 @@ export namespace state { message.show = reader.readBool(); break; case 6: - message.kilometerCode = reader.readString(); + message.kilometerCode = reader.readInt64(); break; case 7: message.dir = reader.readInt32(); diff --git a/xian-ncc-da-message b/xian-ncc-da-message index 0e4f2bd..c92fd31 160000 --- a/xian-ncc-da-message +++ b/xian-ncc-da-message @@ -1 +1 @@ -Subproject commit 0e4f2bd6fbb5eae436685260e622ec7796ae479a +Subproject commit c92fd31a301d06b5bfe5426d3da65203c82e84fb From 630e2c7d0171c10db7c4c6039331e8088817515e Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Thu, 29 Jun 2023 17:37:50 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=B8=80=E9=94=AE=E7=94=9F=E6=88=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/DrawLayout.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index c850163..1e73868 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -16,7 +16,13 @@ 一键关联 - 一键生成 + 一键生成车次窗 + + + 一键生成分隔符 + + + 一键生成计轴 @@ -305,10 +311,19 @@ function buildRelations() { } function oneClickGeneration() { + // 一键生成车次窗 + drawStore.getDrawApp().interactionPlugin(OneClickGenerate.Type).resume(); +} + +function oneClickSeparator() { + //一键生成分隔符 const separatorDraw = drawStore .getDrawApp() .getDrawAssistant(Separator.Type) as SeparatorDraw; separatorDraw.oneGenerates(); +} +function oneClickAxleCounting() { + //一键生成计轴 drawStore.getDrawApp().interactionPlugin(OneClickGenerate.Type).resume(); } From 9a0604d8c8eca6f1bfe7e970fdd8f13d13948159 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Thu, 29 Jun 2023 17:51:31 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=B8=80=E9=94=AE=E7=94=9F=E6=88=90?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trainWindow/oneClickDrawAssistant.ts | 21 ++++++++++++------- src/layouts/DrawLayout.vue | 2 ++ src/stores/draw-store.ts | 1 + 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/graphics/trainWindow/oneClickDrawAssistant.ts b/src/graphics/trainWindow/oneClickDrawAssistant.ts index de16338..c0c52b9 100644 --- a/src/graphics/trainWindow/oneClickDrawAssistant.ts +++ b/src/graphics/trainWindow/oneClickDrawAssistant.ts @@ -10,6 +10,7 @@ import { TrainWindow } from './TrainWindow'; import { TrainWindowDraw } from './TrainWindowDrawAssistant'; import { AxleCounting } from '../axleCounting/AxleCounting'; import { AxleCountingDraw } from '../axleCounting/AxleCountingDrawAssistant'; +import { useDrawStore } from 'src/stores/draw-store'; interface IOneClickData extends GraphicData { get code(): string; // 编号 @@ -56,14 +57,18 @@ export class OneClickGenerateDraw extends GraphicDrawAssistant< this.lineGraph.doRepaint(); } onLeftDown(e: FederatedPointerEvent): void { - const trainWindowDraw = this.app.getDrawAssistant( - TrainWindow.Type - ) as TrainWindowDraw; - trainWindowDraw.oneGenerates(this.toCanvasCoordinates(e.global)); - const axleCountingDraw = this.app.getDrawAssistant( - AxleCounting.Type - ) as AxleCountingDraw; - axleCountingDraw.oneGenerates(this.toCanvasCoordinates(e.global)); + const type = useDrawStore().$state.oneClickType; + if (type == 'TrainWindow') { + const trainWindowDraw = this.app.getDrawAssistant( + TrainWindow.Type + ) as TrainWindowDraw; + trainWindowDraw.oneGenerates(this.toCanvasCoordinates(e.global)); + } else { + const axleCountingDraw = this.app.getDrawAssistant( + AxleCounting.Type + ) as AxleCountingDraw; + axleCountingDraw.oneGenerates(this.toCanvasCoordinates(e.global)); + } this.finish(); } diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index 1e73868..e6b6726 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -312,6 +312,7 @@ function buildRelations() { function oneClickGeneration() { // 一键生成车次窗 + drawStore.oneClickType = 'TrainWindow'; drawStore.getDrawApp().interactionPlugin(OneClickGenerate.Type).resume(); } @@ -324,6 +325,7 @@ function oneClickSeparator() { } function oneClickAxleCounting() { //一键生成计轴 + drawStore.oneClickType = 'AxleCounting'; drawStore.getDrawApp().interactionPlugin(OneClickGenerate.Type).resume(); } diff --git a/src/stores/draw-store.ts b/src/stores/draw-store.ts index a9f14f7..e1a35af 100644 --- a/src/stores/draw-store.ts +++ b/src/stores/draw-store.ts @@ -8,6 +8,7 @@ export const useDrawStore = defineStore('draw', { selectedGraphics: null as JlGraphic[] | null, draftId: null as number | null, draftType: 'Line', + oneClickType: '', }), getters: { drawMode: (state) => state.drawAssistant != null, From 1117ccb8286e601a94d3ce991107d27d9f604a48 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Thu, 29 Jun 2023 17:56:07 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=88=86=E9=9A=94=E7=AC=A6=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/properties/SeparatorProperty.vue | 18 ++++++----------- .../separator/SeparatorDrawAssistant.ts | 20 ++++++++++--------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/components/draw-app/properties/SeparatorProperty.vue b/src/components/draw-app/properties/SeparatorProperty.vue index 81003d2..f5434d9 100644 --- a/src/components/draw-app/properties/SeparatorProperty.vue +++ b/src/components/draw-app/properties/SeparatorProperty.vue @@ -3,7 +3,6 @@ @@ -20,23 +19,18 @@ import { SeparatorData } from 'src/drawApp/graphics/SeparatorInteraction'; import { Separator } from 'src/graphics/separator/Separator'; import { useDrawStore } from 'src/stores/draw-store'; -import { computed, onMounted, reactive, watch } from 'vue'; +import { onMounted, reactive, watch } from 'vue'; const drawStore = useDrawStore(); const separatorModel = reactive(new SeparatorData()); const typeOptions = [ - { label: '左方向', value: 'endA' }, - { label: '右方向', value: 'endB' }, + { label: '区段分隔符', value: 'section' }, + { label: '道岔分隔符', value: 'turnout' }, + { label: '左断路分隔符', value: 'endA' }, + { label: '右断路分隔符', value: 'endB' }, ]; -const showType = computed(() => { - const find = typeOptions.find((item) => { - return item.value == separatorModel.separatorType; - }); - return !!find; -}); - drawStore.$subscribe; watch( () => drawStore.selectedGraphic, diff --git a/src/graphics/separator/SeparatorDrawAssistant.ts b/src/graphics/separator/SeparatorDrawAssistant.ts index 799b1c7..0427d96 100644 --- a/src/graphics/separator/SeparatorDrawAssistant.ts +++ b/src/graphics/separator/SeparatorDrawAssistant.ts @@ -101,21 +101,22 @@ export class SeparatorDraw extends GraphicDrawAssistant< const r = relation.getRelationParam(turnout); port.push(r.param); const other = relation.getOtherRelationParam(turnout); + let t = separatorTypeEnum.section; + if ( + (r.param == 'C' && other.param == 'C') || + (r.g.type == Turnout.Type && + other.g.type == Turnout.Type && + (r.param == 'C' || other.param == 'C')) + ) { + t = separatorTypeEnum.turnout; + } if (!rMap.has(setKey(r))) { - let t = separatorTypeEnum.section; - if (r.param == 'C' && other.param == 'C') { - t = separatorTypeEnum.turnout; - } rMap.set(setKey(r), { ...r, separatorType: t, }); } if (!rMap.has(setKey(other))) { - let t = separatorTypeEnum.section; - if (r.param == 'C' && other.param == 'C') { - t = separatorTypeEnum.turnout; - } rMap.set(setKey(other), { ...other, separatorType: t, @@ -161,7 +162,8 @@ export class SeparatorDraw extends GraphicDrawAssistant< } else if (item.param == 'B') { l = 1; } - p = ps[l][0]; + const lps = ps[l]; + p = lps[lps.length - 1]; } const tps = item.g.localToCanvasPoint(p); separator.position.set(tps.x, tps.y); From e0e28524dc238d5e851d75b2d7230bf335a4a83f Mon Sep 17 00:00:00 2001 From: Yuan Date: Thu, 29 Jun 2023 17:59:58 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E9=81=93=E5=B2=94=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=85=AC=E9=87=8C=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/properties/TurnoutProperty.vue | 36 +++++++++++++++++-- src/drawApp/graphics/TurnoutInteraction.ts | 7 ++++ src/graphics/turnout/Turnout.ts | 3 ++ src/protos/stationLayoutGraphics.ts | 26 ++++++++++++++ 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/components/draw-app/properties/TurnoutProperty.vue b/src/components/draw-app/properties/TurnoutProperty.vue index 75f0d41..10d703f 100644 --- a/src/components/draw-app/properties/TurnoutProperty.vue +++ b/src/components/draw-app/properties/TurnoutProperty.vue @@ -7,6 +7,24 @@ @blur="onUpdate" label="编号" /> + +