From 34ac0ac03c01bddd096ceaa0155e4b18cf42560f Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 10 Jul 2023 17:01:08 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/properties/AxleCountingSectionProperty.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/draw-app/properties/AxleCountingSectionProperty.vue b/src/components/draw-app/properties/AxleCountingSectionProperty.vue index 9d3cf5c..88e7e8c 100644 --- a/src/components/draw-app/properties/AxleCountingSectionProperty.vue +++ b/src/components/draw-app/properties/AxleCountingSectionProperty.vue @@ -40,7 +40,7 @@ 关联的计轴
{ +const axleCountingRelations = computed(() => { const axleCountingSection = drawStore.selectedGraphic as AxleCountingSection; const sectionRelations = axleCountingSection?.relationManage.getRelationsOfGraphicAndOtherType( @@ -112,7 +112,7 @@ const sectionRelations = computed(() => { (relation) => `${ relation.getOtherGraphic(axleCountingSection).datas.code - }(${relation.getOtherRelationParam(axleCountingSection).param})` + }` ); return Array.from(new Set(ref)); }); From 8c717d45dd94543e0ee1c57dabd83d0e88b56046 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Tue, 11 Jul 2023 15:35:35 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E4=B8=8E=E9=81=93=E5=B2=94=E4=BD=8D=E7=BD=AE=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AxleCountingSectionProperty.vue | 62 ++++++---- .../AxleCountingSectionInteraction.ts | 7 ++ .../AxleCountingSection.ts | 13 +- .../AxleCountingSectionAssistant.ts | 100 +++++++++++---- src/protos/stationLayoutGraphics.ts | 115 +++++++++++++++++- 5 files changed, 247 insertions(+), 50 deletions(-) diff --git a/src/components/draw-app/properties/AxleCountingSectionProperty.vue b/src/components/draw-app/properties/AxleCountingSectionProperty.vue index 88e7e8c..c85d1d9 100644 --- a/src/components/draw-app/properties/AxleCountingSectionProperty.vue +++ b/src/components/draw-app/properties/AxleCountingSectionProperty.vue @@ -16,24 +16,6 @@ lazy-rules autogrow /> - - @@ -51,6 +33,23 @@
+ + + + 关联道岔的位置关系 +
+ + {{ item }} + +
+
+
@@ -59,19 +58,17 @@ import { AxleCountingSectionData } from 'src/drawApp/graphics/AxleCountingSectionInteraction'; import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; import { AxleCountingSection } from 'src/graphics/axleCountingSection/AxleCountingSection'; +import { Turnout } from 'src/graphics/turnout/Turnout'; import { useDrawStore } from 'src/stores/draw-store'; import { computed, onMounted, reactive, watch } from 'vue'; const drawStore = useDrawStore(); const axleCountingSectionModel = reactive(new AxleCountingSectionData()); -const kilometerSystem = reactive({ coordinateSystem: '', kilometer: 0 }); -const CoordinateSystemOptions = [ - { label: '车辆段', value: 'DEPOT' }, - { label: '停车场', value: 'PARKING_LOT' }, - { label: '正线', value: 'MAIN_LINE' }, - { label: '换线', value: 'TRANSFER' }, -]; +enum turoutPos { + '正位', + '反位', +} drawStore.$subscribe; watch( @@ -116,4 +113,19 @@ const axleCountingRelations = computed(() => { ); return Array.from(new Set(ref)); }); + +const turnoutRelations = computed(() => { + const axleCountingSection = drawStore.selectedGraphic as AxleCountingSection; + const refTurnoutAndPos: { turnout: Turnout; pos: number }[] = []; + axleCountingSection?.datas.turnoutPosRef.forEach((ref) => { + const refTurout = axleCountingSection.queryStore.queryById( + ref.id + ) as Turnout; + refTurnoutAndPos.push({ turnout: refTurout, pos: ref.position }); + }); + const ref = refTurnoutAndPos.map( + (ref) => `${ref.turnout.datas.code}+${turoutPos[ref.pos]}` + ); + return Array.from(new Set(ref)); +}); diff --git a/src/drawApp/graphics/AxleCountingSectionInteraction.ts b/src/drawApp/graphics/AxleCountingSectionInteraction.ts index 72d3770..4372843 100644 --- a/src/drawApp/graphics/AxleCountingSectionInteraction.ts +++ b/src/drawApp/graphics/AxleCountingSectionInteraction.ts @@ -3,6 +3,7 @@ import { GraphicDataBase } from './GraphicDataBase'; import { IAxleCountingSectionData, AxleCountingSection, + ITurnoutPosRefData, } from 'src/graphics/axleCountingSection/AxleCountingSection'; import { graphicData } from 'src/protos/stationLayoutGraphics'; import { IPointData } from 'pixi.js'; @@ -51,6 +52,12 @@ export class AxleCountingSectionData set pbRef(ref: graphicData.RelatedRef) { this.data.pbRef = ref; } + get turnoutPosRef(): ITurnoutPosRefData[] { + return this.data.turnoutPos; + } + set turnoutPosRef(points: ITurnoutPosRefData[]) { + this.data.turnoutPos = points.map((p) => new graphicData.TurnoutPosRef(p)); + } clone(): AxleCountingSectionData { return new AxleCountingSectionData(this.data.cloneMessage()); } diff --git a/src/graphics/axleCountingSection/AxleCountingSection.ts b/src/graphics/axleCountingSection/AxleCountingSection.ts index 3c445b8..b5b7e97 100644 --- a/src/graphics/axleCountingSection/AxleCountingSection.ts +++ b/src/graphics/axleCountingSection/AxleCountingSection.ts @@ -9,15 +9,24 @@ import { import { IRelatedRefData, protoPort2Data } from '../CommonGraphics'; import { SectionPort } from '../section/Section'; +export interface ITurnoutPosRefData { + get id(): string; //道岔的ID + set id(v: string); + get position(): number; //道岔的正反为,0是正位,1是反位 + set position(v: number); +} + export interface IAxleCountingSectionData extends GraphicData { get code(): string; // 编号 set code(v: string); get points(): IPointData[]; // 线坐标点 set points(points: IPointData[]); - get paRef(): IRelatedRefData | undefined; + get paRef(): IRelatedRefData | undefined; //区段A端关联的设备 set paRef(ref: IRelatedRefData | undefined); - get pbRef(): IRelatedRefData | undefined; + get pbRef(): IRelatedRefData | undefined; //区段B端关联的设备 set pbRef(ref: IRelatedRefData | undefined); + get turnoutPosRef(): ITurnoutPosRefData[]; //关联道岔的正反位 + set turnoutPosRef(ref: ITurnoutPosRefData[]); clone(): IAxleCountingSectionData; copyFrom(data: IAxleCountingSectionData): void; eq(other: IAxleCountingSectionData): boolean; diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index 4246bf5..c6a8e56 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -13,6 +13,7 @@ import { AxleCountingSection, AxleCountingSectionTemplate, AxleCountingSectionConsts, + ITurnoutPosRefData, } from './AxleCountingSection'; import { AxleCounting } from '../axleCounting/AxleCounting'; import { Turnout } from '../turnout/Turnout'; @@ -74,12 +75,11 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< data.transform = this.container.saveTransform(); return true; } - draw(graphics: AxleCounting[], map: Map) { - if ( - map.has(`${graphics[0].id}+${graphics[1].id}`) || - map.has(`${graphics[1].id}+${graphics[0].id}`) - ) - return; + draw( + graphics: AxleCounting[], + commonElement: JlGraphic[], + turoutPos?: number + ) { const axleCountingSection = new AxleCountingSection(); axleCountingSection.loadData(this.graphicTemplate.datas); axleCountingSection.datas.points = [ @@ -89,24 +89,42 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< axleCountingSection.id = GraphicIdGenerator.next(); const paRef = createRelatedRefProto(graphics[0].type, graphics[0].id); const pbRef = createRelatedRefProto(graphics[1].type, graphics[1].id); + const turnoutPosData: ITurnoutPosRefData[] = []; + if (commonElement[0].type == 'Turnout') { + commonElement.forEach((Turnout) => { + if (commonElement.length > 1) { + turnoutPosData.push({ + id: Turnout.id, + position: 0, + }); + } else { + if (turoutPos == 0) { + turnoutPosData.push({ + id: Turnout.id, + position: 0, + }); + } else { + turnoutPosData.push({ + id: Turnout.id, + position: 1, + }); + } + } + }); + } axleCountingSection.datas.paRef = paRef; axleCountingSection.datas.pbRef = pbRef; + axleCountingSection.datas.turnoutPosRef = turnoutPosData; this.storeGraphic(axleCountingSection); axleCountingSection.loadRelations(); } oneGenerates() { - const map = new Map(); const axleCountingSections = this.app.queryStore.queryByType( AxleCountingSection.Type ); - axleCountingSections.forEach((axleCountingSection) => { - map.set( - `${axleCountingSection.datas.paRef?.id}+${axleCountingSection.datas.pbRef?.id}`, - 1 - ); - }); + this.app.deleteGraphics(...axleCountingSections); const axleCountings = this.app.queryStore.queryByType( AxleCounting.Type ); @@ -124,6 +142,8 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< if (commonElementId) { const commonElement = this.app.queryStore.queryById(commonElementId); let draw = true; + let turoutPos = 0; + //道岔BC端处的计轴不构成计轴区段 if (commonElement.type == 'Turnout') { let targetPort, port; axleCounting.datas.axleCountingRef.forEach((ref) => { @@ -142,9 +162,16 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< ) { draw = false; } + if (targetPort == 2 || port == 2) { + turoutPos = 1; + } } if (draw) { - this.draw([axleCounting, axleCountings[i]], map); + this.draw( + [axleCounting, axleCountings[i]], + [commonElement], + turoutPos + ); } } if (hasSamePosition(axleCounting, axleCountings[i])) { @@ -152,7 +179,11 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< } } }); - const fourAxleCounting: AxleCounting[] = []; + //补4个道岔处的BB连接处的计轴区段 + const fourAxleCounting: { + axleCounting: AxleCounting; + refTurout: Turnout; + }[] = []; hasfourTurnout.forEach((axleCountings) => { axleCountings.forEach((axleCounting) => { //计轴关联的道岔 @@ -176,7 +207,10 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< refAxleCounting.id !== axleCountings[0].id && refAxleCounting.id !== axleCountings[1].id ) { - fourAxleCounting.push(refAxleCounting); + fourAxleCounting.push({ + axleCounting: refAxleCounting, + refTurout: refTurnout, + }); } }); }); @@ -185,16 +219,38 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< for (let x = 0; x < fourAxleCounting.length; x += 4) { const AxleCountings = fourAxleCounting.slice(x, x + 4); for (let y = 0; y < 4; y++) { - if (fourAxleCounting[x].id == AxleCountings[y].id) continue; - if (fourAxleCounting[x].y == AxleCountings[y].y) { - this.draw([fourAxleCounting[x], AxleCountings[y]], map); + if ( + fourAxleCounting[x].axleCounting.id == + AxleCountings[y].axleCounting.id + ) + continue; + if ( + fourAxleCounting[x].axleCounting.y == AxleCountings[y].axleCounting.y + ) { + this.draw( + [fourAxleCounting[x].axleCounting, AxleCountings[y].axleCounting], + [fourAxleCounting[x].refTurout, AxleCountings[y].refTurout] + ); break; } } for (let y = 0; y < 4; y++) { - if (fourAxleCounting[x + 1].id == AxleCountings[y].id) continue; - if (fourAxleCounting[x + 1].y == AxleCountings[y].y) { - this.draw([fourAxleCounting[x + 1], AxleCountings[y]], map); + if ( + fourAxleCounting[x + 1].axleCounting.id == + AxleCountings[y].axleCounting.id + ) + continue; + if ( + fourAxleCounting[x + 1].axleCounting.y == + AxleCountings[y].axleCounting.y + ) { + this.draw( + [ + fourAxleCounting[x + 1].axleCounting, + AxleCountings[y].axleCounting, + ], + [fourAxleCounting[x + 1].refTurout, AxleCountings[y].refTurout] + ); break; } } diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index a73b14d..d8fedea 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -3359,6 +3359,96 @@ export namespace graphicData { C = 2 } } + export class TurnoutPosRef extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + id?: string; + position?: number; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("id" in data && data.id != undefined) { + this.id = data.id; + } + if ("position" in data && data.position != undefined) { + this.position = data.position; + } + } + } + get id() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + set id(value: string) { + pb_1.Message.setField(this, 1, value); + } + get position() { + return pb_1.Message.getFieldWithDefault(this, 2, 0) as number; + } + set position(value: number) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + id?: string; + position?: number; + }): TurnoutPosRef { + const message = new TurnoutPosRef({}); + if (data.id != null) { + message.id = data.id; + } + if (data.position != null) { + message.position = data.position; + } + return message; + } + toObject() { + const data: { + id?: string; + position?: number; + } = {}; + if (this.id != null) { + data.id = this.id; + } + if (this.position != null) { + data.position = this.position; + } + 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.position != 0) + writer.writeInt32(2, this.position); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): TurnoutPosRef { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TurnoutPosRef(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.id = reader.readString(); + break; + case 2: + message.position = reader.readInt32(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): TurnoutPosRef { + return TurnoutPosRef.deserialize(bytes); + } + } export class Separator extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -3622,9 +3712,10 @@ export namespace graphicData { points?: Point[]; paRef?: RelatedRef; pbRef?: RelatedRef; + turnoutPos?: TurnoutPosRef[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 6], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("common" in data && data.common != undefined) { this.common = data.common; @@ -3641,6 +3732,9 @@ export namespace graphicData { if ("pbRef" in data && data.pbRef != undefined) { this.pbRef = data.pbRef; } + if ("turnoutPos" in data && data.turnoutPos != undefined) { + this.turnoutPos = data.turnoutPos; + } } } get common() { @@ -3682,12 +3776,19 @@ export namespace graphicData { get has_pbRef() { return pb_1.Message.getField(this, 5) != null; } + get turnoutPos() { + return pb_1.Message.getRepeatedWrapperField(this, TurnoutPosRef, 6) as TurnoutPosRef[]; + } + set turnoutPos(value: TurnoutPosRef[]) { + pb_1.Message.setRepeatedWrapperField(this, 6, value); + } static fromObject(data: { common?: ReturnType; code?: string; points?: ReturnType[]; paRef?: ReturnType; pbRef?: ReturnType; + turnoutPos?: ReturnType[]; }): AxleCountingSection { const message = new AxleCountingSection({}); if (data.common != null) { @@ -3705,6 +3806,9 @@ export namespace graphicData { if (data.pbRef != null) { message.pbRef = RelatedRef.fromObject(data.pbRef); } + if (data.turnoutPos != null) { + message.turnoutPos = data.turnoutPos.map(item => TurnoutPosRef.fromObject(item)); + } return message; } toObject() { @@ -3714,6 +3818,7 @@ export namespace graphicData { points?: ReturnType[]; paRef?: ReturnType; pbRef?: ReturnType; + turnoutPos?: ReturnType[]; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -3730,6 +3835,9 @@ export namespace graphicData { if (this.pbRef != null) { data.pbRef = this.pbRef.toObject(); } + if (this.turnoutPos != null) { + data.turnoutPos = this.turnoutPos.map((item: TurnoutPosRef) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -3746,6 +3854,8 @@ export namespace graphicData { writer.writeMessage(4, this.paRef, () => this.paRef.serialize(writer)); if (this.has_pbRef) writer.writeMessage(5, this.pbRef, () => this.pbRef.serialize(writer)); + if (this.turnoutPos.length) + writer.writeRepeatedMessage(6, this.turnoutPos, (item: TurnoutPosRef) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -3770,6 +3880,9 @@ export namespace graphicData { case 5: reader.readMessage(message.pbRef, () => message.pbRef = RelatedRef.deserialize(reader)); break; + case 6: + reader.readMessage(message.turnoutPos, () => pb_1.Message.addToRepeatedWrapperField(message, 6, TurnoutPosRef.deserialize(reader), TurnoutPosRef)); + break; default: reader.skipField(); } } From 1c11f4eb0de9be98a7b0e37e4d716c7a19eeb577 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Tue, 11 Jul 2023 16:18:02 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=92=8C=E8=AE=A1?= =?UTF-8?q?=E8=BD=B4=E7=9A=84=E7=B4=A2=E5=BC=95=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/AxleCountingProperty.vue | 9 ++++ .../AxleCountingSectionProperty.vue | 9 ++++ .../graphics/AxleCountingInteraction.ts | 6 +++ .../AxleCountingSectionInteraction.ts | 6 +++ src/graphics/axleCounting/AxleCounting.ts | 2 + .../AxleCountingSection.ts | 2 + src/protos/stationLayoutGraphics.ts | 46 +++++++++++++++++++ 7 files changed, 80 insertions(+) diff --git a/src/components/draw-app/properties/AxleCountingProperty.vue b/src/components/draw-app/properties/AxleCountingProperty.vue index c503ea4..22244b8 100644 --- a/src/components/draw-app/properties/AxleCountingProperty.vue +++ b/src/components/draw-app/properties/AxleCountingProperty.vue @@ -6,6 +6,15 @@ v-model="axleCountingModel.id" label="id" hint="" + /> + + new graphicData.TurnoutPosRef(p)); } + get indexNumber(): number { + return this.data.indexNumber; + } + set indexNumber(v: number) { + this.data.indexNumber = v; + } clone(): AxleCountingSectionData { return new AxleCountingSectionData(this.data.cloneMessage()); } diff --git a/src/graphics/axleCounting/AxleCounting.ts b/src/graphics/axleCounting/AxleCounting.ts index 5538fb9..1334812 100644 --- a/src/graphics/axleCounting/AxleCounting.ts +++ b/src/graphics/axleCounting/AxleCounting.ts @@ -16,6 +16,8 @@ export interface IAxleCountingData extends GraphicData { set kilometerSystem(v: KilometerSystem); get axleCountingRef(): IRelatedRefData[]; //关联的设备 set axleCountingRef(ref: IRelatedRefData[]); + get indexNumber(): number; // 索引编号 + set indexNumber(v: number); clone(): IAxleCountingData; copyFrom(data: IAxleCountingData): void; eq(other: IAxleCountingData): boolean; diff --git a/src/graphics/axleCountingSection/AxleCountingSection.ts b/src/graphics/axleCountingSection/AxleCountingSection.ts index b5b7e97..c2e36a0 100644 --- a/src/graphics/axleCountingSection/AxleCountingSection.ts +++ b/src/graphics/axleCountingSection/AxleCountingSection.ts @@ -27,6 +27,8 @@ export interface IAxleCountingSectionData extends GraphicData { set pbRef(ref: IRelatedRefData | undefined); get turnoutPosRef(): ITurnoutPosRefData[]; //关联道岔的正反位 set turnoutPosRef(ref: ITurnoutPosRefData[]); + get indexNumber(): number; // 索引编号 + set indexNumber(v: number); clone(): IAxleCountingSectionData; copyFrom(data: IAxleCountingSectionData): void; eq(other: IAxleCountingSectionData): boolean; diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index d8fedea..3956e27 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -2080,6 +2080,7 @@ export namespace graphicData { code?: string; kilometerSystem?: KilometerSystem; axleCountingRef?: RelatedRef[]; + indexNumber?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4], this.#one_of_decls); @@ -2096,6 +2097,9 @@ export namespace graphicData { if ("axleCountingRef" in data && data.axleCountingRef != undefined) { this.axleCountingRef = data.axleCountingRef; } + if ("indexNumber" in data && data.indexNumber != undefined) { + this.indexNumber = data.indexNumber; + } } } get common() { @@ -2128,11 +2132,18 @@ export namespace graphicData { set axleCountingRef(value: RelatedRef[]) { pb_1.Message.setRepeatedWrapperField(this, 4, value); } + get indexNumber() { + return pb_1.Message.getFieldWithDefault(this, 5, 0) as number; + } + set indexNumber(value: number) { + pb_1.Message.setField(this, 5, value); + } static fromObject(data: { common?: ReturnType; code?: string; kilometerSystem?: ReturnType; axleCountingRef?: ReturnType[]; + indexNumber?: number; }): AxleCounting { const message = new AxleCounting({}); if (data.common != null) { @@ -2147,6 +2158,9 @@ export namespace graphicData { if (data.axleCountingRef != null) { message.axleCountingRef = data.axleCountingRef.map(item => RelatedRef.fromObject(item)); } + if (data.indexNumber != null) { + message.indexNumber = data.indexNumber; + } return message; } toObject() { @@ -2155,6 +2169,7 @@ export namespace graphicData { code?: string; kilometerSystem?: ReturnType; axleCountingRef?: ReturnType[]; + indexNumber?: number; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -2168,6 +2183,9 @@ export namespace graphicData { if (this.axleCountingRef != null) { data.axleCountingRef = this.axleCountingRef.map((item: RelatedRef) => item.toObject()); } + if (this.indexNumber != null) { + data.indexNumber = this.indexNumber; + } return data; } serialize(): Uint8Array; @@ -2182,6 +2200,8 @@ export namespace graphicData { writer.writeMessage(3, this.kilometerSystem, () => this.kilometerSystem.serialize(writer)); if (this.axleCountingRef.length) writer.writeRepeatedMessage(4, this.axleCountingRef, (item: RelatedRef) => item.serialize(writer)); + if (this.indexNumber != 0) + writer.writeInt32(5, this.indexNumber); if (!w) return writer.getResultBuffer(); } @@ -2203,6 +2223,9 @@ export namespace graphicData { case 4: reader.readMessage(message.axleCountingRef, () => pb_1.Message.addToRepeatedWrapperField(message, 4, RelatedRef.deserialize(reader), RelatedRef)); break; + case 5: + message.indexNumber = reader.readInt32(); + break; default: reader.skipField(); } } @@ -3713,6 +3736,7 @@ export namespace graphicData { paRef?: RelatedRef; pbRef?: RelatedRef; turnoutPos?: TurnoutPosRef[]; + indexNumber?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 6], this.#one_of_decls); @@ -3735,6 +3759,9 @@ export namespace graphicData { if ("turnoutPos" in data && data.turnoutPos != undefined) { this.turnoutPos = data.turnoutPos; } + if ("indexNumber" in data && data.indexNumber != undefined) { + this.indexNumber = data.indexNumber; + } } } get common() { @@ -3782,6 +3809,12 @@ export namespace graphicData { set turnoutPos(value: TurnoutPosRef[]) { pb_1.Message.setRepeatedWrapperField(this, 6, value); } + get indexNumber() { + return pb_1.Message.getFieldWithDefault(this, 7, 0) as number; + } + set indexNumber(value: number) { + pb_1.Message.setField(this, 7, value); + } static fromObject(data: { common?: ReturnType; code?: string; @@ -3789,6 +3822,7 @@ export namespace graphicData { paRef?: ReturnType; pbRef?: ReturnType; turnoutPos?: ReturnType[]; + indexNumber?: number; }): AxleCountingSection { const message = new AxleCountingSection({}); if (data.common != null) { @@ -3809,6 +3843,9 @@ export namespace graphicData { if (data.turnoutPos != null) { message.turnoutPos = data.turnoutPos.map(item => TurnoutPosRef.fromObject(item)); } + if (data.indexNumber != null) { + message.indexNumber = data.indexNumber; + } return message; } toObject() { @@ -3819,6 +3856,7 @@ export namespace graphicData { paRef?: ReturnType; pbRef?: ReturnType; turnoutPos?: ReturnType[]; + indexNumber?: number; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -3838,6 +3876,9 @@ export namespace graphicData { if (this.turnoutPos != null) { data.turnoutPos = this.turnoutPos.map((item: TurnoutPosRef) => item.toObject()); } + if (this.indexNumber != null) { + data.indexNumber = this.indexNumber; + } return data; } serialize(): Uint8Array; @@ -3856,6 +3897,8 @@ export namespace graphicData { writer.writeMessage(5, this.pbRef, () => this.pbRef.serialize(writer)); if (this.turnoutPos.length) writer.writeRepeatedMessage(6, this.turnoutPos, (item: TurnoutPosRef) => item.serialize(writer)); + if (this.indexNumber != 0) + writer.writeInt32(7, this.indexNumber); if (!w) return writer.getResultBuffer(); } @@ -3883,6 +3926,9 @@ export namespace graphicData { case 6: reader.readMessage(message.turnoutPos, () => pb_1.Message.addToRepeatedWrapperField(message, 6, TurnoutPosRef.deserialize(reader), TurnoutPosRef)); break; + case 7: + message.indexNumber = reader.readInt32(); + break; default: reader.skipField(); } } From c23fdb4cbfe5dcd296db183566c54e5afed2f23e Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Tue, 11 Jul 2023 16:44:04 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5?= =?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/components/draw-app/DrawProperties.vue | 6 + .../properties/LogicSectionProperty.vue | 98 +++++++ .../graphics/LogicSectionInteraction.ts | 22 +- src/graphics/logicSection/LogicSection.ts | 34 +-- .../logicSection/LogicSectionDrawAssistant.ts | 173 +++--------- src/protos/device_state.ts | 249 ++++++++++++++++++ src/protos/stationLayoutGraphics.ts | 180 ++++++++++++- 7 files changed, 577 insertions(+), 185 deletions(-) create mode 100644 src/components/draw-app/properties/LogicSectionProperty.vue diff --git a/src/components/draw-app/DrawProperties.vue b/src/components/draw-app/DrawProperties.vue index 788d6ee..17fb7bb 100644 --- a/src/components/draw-app/DrawProperties.vue +++ b/src/components/draw-app/DrawProperties.vue @@ -77,6 +77,10 @@ drawStore.selectedGraphicType === AxleCountingSection.Type " > + + @@ -104,6 +108,7 @@ import StationProperty from './properties/StationProperty.vue'; import TrainWindowProperty from './properties/TrainWindowProperty.vue'; import AxleCountingProperty from './properties/AxleCountingProperty.vue'; import AxleCountingSectionProperty from './properties/AxleCountingSectionProperty.vue'; +import LogicSectionProperty from './properties/LogicSectionProperty.vue'; import SignalProperty from './properties/SignalProperty.vue'; import TurnoutProperty from './properties/TurnoutProperty.vue'; import SectionProperty from './properties/SectionProperty.vue'; @@ -121,6 +126,7 @@ import { Section } from 'src/graphics/section/Section'; import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow'; import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; import { AxleCountingSection } from 'src/graphics/axleCountingSection/AxleCountingSection'; +import { LogicSection } from 'src/graphics/logicSection/LogicSection'; import { Separator } from 'src/graphics/separator/Separator'; import { SectionLink } from 'src/graphics/sectionLink/SectionLink'; diff --git a/src/components/draw-app/properties/LogicSectionProperty.vue b/src/components/draw-app/properties/LogicSectionProperty.vue new file mode 100644 index 0000000..93c9545 --- /dev/null +++ b/src/components/draw-app/properties/LogicSectionProperty.vue @@ -0,0 +1,98 @@ + + + diff --git a/src/drawApp/graphics/LogicSectionInteraction.ts b/src/drawApp/graphics/LogicSectionInteraction.ts index a800c88..a8bef9f 100644 --- a/src/drawApp/graphics/LogicSectionInteraction.ts +++ b/src/drawApp/graphics/LogicSectionInteraction.ts @@ -11,7 +11,7 @@ export class LogicSectionData extends GraphicDataBase implements ILogicSectionData { - constructor(data?: graphicData.AxleCountingSection) { + constructor(data?: graphicData.LogicSection) { let logicSection; if (!data) { logicSection = new graphicData.AxleCountingSection({ @@ -22,8 +22,8 @@ export class LogicSectionData } super(logicSection); } - public get data(): graphicData.AxleCountingSection { - return this.getData(); + public get data(): graphicData.LogicSection { + return this.getData(); } get code(): string { return this.data.code; @@ -39,17 +39,17 @@ export class LogicSectionData (p) => new graphicData.Point({ x: p.x, y: p.y }) ); } - get paRef(): graphicData.RelatedRef { - return this.data.paRef; + get axleSectionId(): string { + return this.data.axleSectionId; } - set paRef(ref: graphicData.RelatedRef) { - this.data.paRef = ref; + set axleSectionId(v: string) { + this.data.axleSectionId = v; } - get pbRef(): graphicData.RelatedRef { - return this.data.pbRef; + get indexNumber(): number { + return this.data.indexNumber; } - set pbRef(ref: graphicData.RelatedRef) { - this.data.pbRef = ref; + set indexNumber(v: number) { + this.data.indexNumber = v; } clone(): LogicSectionData { return new LogicSectionData(this.data.cloneMessage()); diff --git a/src/graphics/logicSection/LogicSection.ts b/src/graphics/logicSection/LogicSection.ts index 3e6ec3d..2001de4 100644 --- a/src/graphics/logicSection/LogicSection.ts +++ b/src/graphics/logicSection/LogicSection.ts @@ -6,18 +6,16 @@ import { JlGraphicTemplate, VectorText, } from 'src/jl-graphic'; -import { IRelatedRefData, protoPort2Data } from '../CommonGraphics'; -import { SectionPort } from '../section/Section'; export interface ILogicSectionData extends GraphicData { get code(): string; // 编号 set code(v: string); get points(): IPointData[]; // 线坐标点 set points(points: IPointData[]); - get paRef(): IRelatedRefData | undefined; - set paRef(ref: IRelatedRefData | undefined); - get pbRef(): IRelatedRefData | undefined; - set pbRef(ref: IRelatedRefData | undefined); + get axleSectionId(): string; // 计轴区段ID + set axleSectionId(v: string); + get indexNumber(): number; // 索引编号 + set indexNumber(v: number); clone(): ILogicSectionData; copyFrom(data: ILogicSectionData): void; eq(other: ILogicSectionData): boolean; @@ -87,23 +85,13 @@ export class LogicSection extends JlGraphic { this.updateData(old); } loadRelations() { - if (this.datas?.paRef?.id) { - this.relationManage.addRelation( - new GraphicRelationParam(this, SectionPort.A), - new GraphicRelationParam( - this.queryStore.queryById(this.datas.paRef.id), - protoPort2Data(this.datas.paRef.devicePort) - ) - ); - } - if (this.datas?.pbRef?.id) { - this.relationManage.addRelation( - new GraphicRelationParam(this, SectionPort.B), - new GraphicRelationParam( - this.queryStore.queryById(this.datas.pbRef.id), - protoPort2Data(this.datas.pbRef.devicePort) - ) - ); + if (this.datas?.axleSectionId) { + const axleSection = this.queryStore.queryById(this.datas.axleSectionId); + axleSection && + this.relationManage.addRelation( + new GraphicRelationParam(this), + new GraphicRelationParam(axleSection) + ); } } } diff --git a/src/graphics/logicSection/LogicSectionDrawAssistant.ts b/src/graphics/logicSection/LogicSectionDrawAssistant.ts index d04d76f..489d767 100644 --- a/src/graphics/logicSection/LogicSectionDrawAssistant.ts +++ b/src/graphics/logicSection/LogicSectionDrawAssistant.ts @@ -1,7 +1,5 @@ -import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js'; +import { FederatedPointerEvent, IHitArea, Point } from 'pixi.js'; import { - AbsorbableLine, - AbsorbablePosition, GraphicDrawAssistant, GraphicIdGenerator, GraphicInteractionPlugin, @@ -16,28 +14,9 @@ import { LogicSectionTemplate, LogicSectionConsts, } from './LogicSection'; -import { AxleCounting } from '../axleCounting/AxleCounting'; import { Turnout } from '../turnout/Turnout'; -import { createRelatedRefProto } from '../CommonGraphics'; - -function hasCommonElements(arr1: string[], arr2: string[]) { - for (let i = 0; i < arr1.length; i++) { - if (arr2.includes(arr1[i])) { - return arr1[i]; - } - } - return false; -} - -function hasSamePosition(point1: IPointData, point2: IPointData): boolean { - if ( - Math.abs(point1.x - point2.x) < 20 && - Math.abs(point1.y - point2.y) < 20 - ) { - return true; - } - return false; -} +import { LogicSectionData } from 'src/drawApp/graphics/LogicSectionInteraction'; +import { AxleCountingSection } from '../axleCountingSection/AxleCountingSection'; export interface ILogicSectionDrawOptions { newData: () => ILogicSectionData; @@ -76,20 +55,10 @@ export class LogicSectionDraw extends GraphicDrawAssistant< data.transform = this.container.saveTransform(); return true; } - draw(graphics: JlGraphic[], map: Map) { - if ( - map.has(`${graphics[0].id}+${graphics[1].id}`) || - map.has(`${graphics[1].id}+${graphics[0].id}`) - ) - return; + draw(data: ILogicSectionData) { const logicSection = new LogicSection(); - logicSection.loadData(this.graphicTemplate.datas); - logicSection.datas.points = [graphics[0].position, graphics[1].position]; + logicSection.loadData(data); logicSection.id = GraphicIdGenerator.next(); - const paRef = createRelatedRefProto(graphics[0].type, graphics[0].id); - const pbRef = createRelatedRefProto(graphics[1].type, graphics[1].id); - logicSection.datas.paRef = paRef; - logicSection.datas.pbRef = pbRef; this.storeGraphic(logicSection); logicSection.loadRelations(); } @@ -99,118 +68,38 @@ export class LogicSectionDraw extends GraphicDrawAssistant< const logicSections = this.app.queryStore.queryByType( LogicSection.Type ); + // this.app.deleteGraphics(...logicSections); + // return; logicSections.forEach((logicSection) => { - map.set( - `${logicSection.datas.paRef?.id}+${logicSection.datas.pbRef?.id}`, - 1 - ); + map.set(`${logicSection.datas.axleSectionId}`, 1); }); - const axleCountings = this.app.queryStore.queryByType( - AxleCounting.Type - ); - const hasfourTurnout: AxleCounting[][] = []; - axleCountings.forEach((axleCounting) => { - const refDeviceTarget = axleCounting.datas.axleCountingRef.map( - (ref) => ref.id + const axleCountingSections = + this.app.queryStore.queryByType( + AxleCountingSection.Type ); - for (let i = 0; i < axleCountings.length - 1; i++) { - if (axleCountings[i].id == axleCounting.id) return; - const refDevice = axleCountings[i].datas.axleCountingRef.map( - (ref) => ref.id - ); - const commonElementId = hasCommonElements(refDeviceTarget, refDevice); - if (commonElementId) { - const commonElement = this.app.queryStore.queryById(commonElementId); - let draw = true; - if (commonElement.type == 'Turnout') { - let targetPort, port; - axleCounting.datas.axleCountingRef.forEach((ref) => { - if (ref.id == commonElementId) { - targetPort = ref.devicePort; - } - }); - axleCountings[i].datas.axleCountingRef.forEach((ref) => { - if (ref.id == commonElementId) { - port = ref.devicePort; - } - }); - if ( - (targetPort == 1 && port == 2) || - (targetPort == 2 && port == 1) - ) { - draw = false; - } - } - if (draw) { - this.draw([axleCounting, axleCountings[i]], map); - } - } - if (hasSamePosition(axleCounting, axleCountings[i])) { - hasfourTurnout.push([axleCounting, axleCountings[i]]); - } + axleCountingSections.forEach((axleCountingSection) => { + if (map.has(`${axleCountingSection.id}`)) { + return; } - }); - const fourAxleCounting: AxleCounting[] = []; - hasfourTurnout.forEach((axleCountings) => { - axleCountings.forEach((axleCounting) => { - //计轴关联的道岔 - const axleCountingRelations = - axleCounting.relationManage.getRelationsOfGraphicAndOtherType( - axleCounting, - Turnout.Type - ); - axleCountingRelations.forEach((relation) => { - const refTurnout = relation.getOtherGraphic(axleCounting); - //道岔关联的计轴 - const turnoutRelations = - refTurnout.relationManage.getRelationsOfGraphicAndOtherType( - refTurnout, - AxleCounting.Type - ); - turnoutRelations.forEach((relation) => { - const refAxleCounting = - relation.getOtherGraphic(refTurnout); - if ( - refAxleCounting.id !== axleCountings[0].id && - refAxleCounting.id !== axleCountings[1].id - ) { - fourAxleCounting.push(refAxleCounting); - } - }); + const turnoutPosRef = axleCountingSection.datas.turnoutPosRef; + if (turnoutPosRef.length > 0) { + turnoutPosRef.forEach((turnout) => { + if (turnout.position == 1) { + const t = this.app.queryStore.queryById(turnout.id) as Turnout; + const data = new LogicSectionData(); + data.points = [ + t.position, + ...t.localToCanvasPoints(...t.datas.pointC), + ]; + data.axleSectionId = axleCountingSection.id; + this.draw(data); + } }); - }); - }); - for (let x = 0; x < fourAxleCounting.length; x += 4) { - const AxleCountings = fourAxleCounting.slice(x, x + 4); - for (let y = 0; y < 4; y++) { - if (fourAxleCounting[x].id == AxleCountings[y].id) continue; - if (fourAxleCounting[x].y == AxleCountings[y].y) { - this.draw([fourAxleCounting[x], AxleCountings[y]], map); - break; - } } - for (let y = 0; y < 4; y++) { - if (fourAxleCounting[x + 1].id == AxleCountings[y].id) continue; - if (fourAxleCounting[x + 1].y == AxleCountings[y].y) { - this.draw([fourAxleCounting[x + 1], AxleCountings[y]], map); - break; - } - } - } - const turnouts = this.app.queryStore.queryByType(Turnout.Type); - turnouts.forEach((turnout) => { - const turnoutRelations = - turnout.relationManage.getRelationsOfGraphicAndOtherType( - turnout, - AxleCounting.Type - ); - turnoutRelations.forEach((ref) => { - const t = ref.getRelationParam(turnout); - const other = ref.getOtherGraphic(turnout) as AxleCounting; - if (t.param == 'C') { - this.draw([turnout, other], map); - } - }); + const data = new LogicSectionData(); + data.points = axleCountingSection.datas.points; + data.axleSectionId = axleCountingSection.id; + this.draw(data); }); } } diff --git a/src/protos/device_state.ts b/src/protos/device_state.ts index fa49ba8..6301baa 100644 --- a/src/protos/device_state.ts +++ b/src/protos/device_state.ts @@ -509,4 +509,253 @@ export namespace state { return TrainState.deserialize(bytes); } } + export class VariationStatus extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + updatedTrain?: TrainState[]; + removedTrainId?: string[]; + updatedSwitch?: SwitchState[]; + updatedSection?: SectionState[]; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2, 3, 4], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("updatedTrain" in data && data.updatedTrain != undefined) { + this.updatedTrain = data.updatedTrain; + } + if ("removedTrainId" in data && data.removedTrainId != undefined) { + this.removedTrainId = data.removedTrainId; + } + if ("updatedSwitch" in data && data.updatedSwitch != undefined) { + this.updatedSwitch = data.updatedSwitch; + } + if ("updatedSection" in data && data.updatedSection != undefined) { + this.updatedSection = data.updatedSection; + } + } + } + get updatedTrain() { + return pb_1.Message.getRepeatedWrapperField(this, TrainState, 1) as TrainState[]; + } + set updatedTrain(value: TrainState[]) { + pb_1.Message.setRepeatedWrapperField(this, 1, value); + } + get removedTrainId() { + return pb_1.Message.getFieldWithDefault(this, 2, []) as string[]; + } + set removedTrainId(value: string[]) { + pb_1.Message.setField(this, 2, value); + } + get updatedSwitch() { + return pb_1.Message.getRepeatedWrapperField(this, SwitchState, 3) as SwitchState[]; + } + set updatedSwitch(value: SwitchState[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); + } + get updatedSection() { + return pb_1.Message.getRepeatedWrapperField(this, SectionState, 4) as SectionState[]; + } + set updatedSection(value: SectionState[]) { + pb_1.Message.setRepeatedWrapperField(this, 4, value); + } + static fromObject(data: { + updatedTrain?: ReturnType[]; + removedTrainId?: string[]; + updatedSwitch?: ReturnType[]; + updatedSection?: ReturnType[]; + }): VariationStatus { + const message = new VariationStatus({}); + if (data.updatedTrain != null) { + message.updatedTrain = data.updatedTrain.map(item => TrainState.fromObject(item)); + } + if (data.removedTrainId != null) { + message.removedTrainId = data.removedTrainId; + } + if (data.updatedSwitch != null) { + message.updatedSwitch = data.updatedSwitch.map(item => SwitchState.fromObject(item)); + } + if (data.updatedSection != null) { + message.updatedSection = data.updatedSection.map(item => SectionState.fromObject(item)); + } + return message; + } + toObject() { + const data: { + updatedTrain?: ReturnType[]; + removedTrainId?: string[]; + updatedSwitch?: ReturnType[]; + updatedSection?: ReturnType[]; + } = {}; + if (this.updatedTrain != null) { + data.updatedTrain = this.updatedTrain.map((item: TrainState) => item.toObject()); + } + if (this.removedTrainId != null) { + data.removedTrainId = this.removedTrainId; + } + if (this.updatedSwitch != null) { + data.updatedSwitch = this.updatedSwitch.map((item: SwitchState) => item.toObject()); + } + if (this.updatedSection != null) { + data.updatedSection = this.updatedSection.map((item: SectionState) => 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.updatedTrain.length) + writer.writeRepeatedMessage(1, this.updatedTrain, (item: TrainState) => item.serialize(writer)); + if (this.removedTrainId.length) + writer.writeRepeatedString(2, this.removedTrainId); + if (this.updatedSwitch.length) + writer.writeRepeatedMessage(3, this.updatedSwitch, (item: SwitchState) => item.serialize(writer)); + if (this.updatedSection.length) + writer.writeRepeatedMessage(4, this.updatedSection, (item: SectionState) => item.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): VariationStatus { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new VariationStatus(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.updatedTrain, () => pb_1.Message.addToRepeatedWrapperField(message, 1, TrainState.deserialize(reader), TrainState)); + break; + case 2: + pb_1.Message.addToRepeatedField(message, 2, reader.readString()); + break; + case 3: + reader.readMessage(message.updatedSwitch, () => pb_1.Message.addToRepeatedWrapperField(message, 3, SwitchState.deserialize(reader), SwitchState)); + break; + case 4: + reader.readMessage(message.updatedSection, () => pb_1.Message.addToRepeatedWrapperField(message, 4, SectionState.deserialize(reader), SectionState)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): VariationStatus { + return VariationStatus.deserialize(bytes); + } + } + export class AllDevicesStatus extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + trainState?: TrainState[]; + switchState?: SwitchState[]; + sectionState?: SectionState[]; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2, 3], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("trainState" in data && data.trainState != undefined) { + this.trainState = data.trainState; + } + if ("switchState" in data && data.switchState != undefined) { + this.switchState = data.switchState; + } + if ("sectionState" in data && data.sectionState != undefined) { + this.sectionState = data.sectionState; + } + } + } + get trainState() { + return pb_1.Message.getRepeatedWrapperField(this, TrainState, 1) as TrainState[]; + } + set trainState(value: TrainState[]) { + pb_1.Message.setRepeatedWrapperField(this, 1, value); + } + get switchState() { + return pb_1.Message.getRepeatedWrapperField(this, SwitchState, 2) as SwitchState[]; + } + set switchState(value: SwitchState[]) { + pb_1.Message.setRepeatedWrapperField(this, 2, value); + } + get sectionState() { + return pb_1.Message.getRepeatedWrapperField(this, SectionState, 3) as SectionState[]; + } + set sectionState(value: SectionState[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); + } + static fromObject(data: { + trainState?: ReturnType[]; + switchState?: ReturnType[]; + sectionState?: ReturnType[]; + }): AllDevicesStatus { + const message = new AllDevicesStatus({}); + if (data.trainState != null) { + message.trainState = data.trainState.map(item => TrainState.fromObject(item)); + } + if (data.switchState != null) { + message.switchState = data.switchState.map(item => SwitchState.fromObject(item)); + } + if (data.sectionState != null) { + message.sectionState = data.sectionState.map(item => SectionState.fromObject(item)); + } + return message; + } + toObject() { + const data: { + trainState?: ReturnType[]; + switchState?: ReturnType[]; + sectionState?: ReturnType[]; + } = {}; + if (this.trainState != null) { + data.trainState = this.trainState.map((item: TrainState) => item.toObject()); + } + if (this.switchState != null) { + data.switchState = this.switchState.map((item: SwitchState) => item.toObject()); + } + if (this.sectionState != null) { + data.sectionState = this.sectionState.map((item: SectionState) => 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.trainState.length) + writer.writeRepeatedMessage(1, this.trainState, (item: TrainState) => item.serialize(writer)); + if (this.switchState.length) + writer.writeRepeatedMessage(2, this.switchState, (item: SwitchState) => item.serialize(writer)); + if (this.sectionState.length) + writer.writeRepeatedMessage(3, this.sectionState, (item: SectionState) => item.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): AllDevicesStatus { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new AllDevicesStatus(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.trainState, () => pb_1.Message.addToRepeatedWrapperField(message, 1, TrainState.deserialize(reader), TrainState)); + break; + case 2: + reader.readMessage(message.switchState, () => pb_1.Message.addToRepeatedWrapperField(message, 2, SwitchState.deserialize(reader), SwitchState)); + break; + case 3: + reader.readMessage(message.sectionState, () => pb_1.Message.addToRepeatedWrapperField(message, 3, SectionState.deserialize(reader), SectionState)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): AllDevicesStatus { + return AllDevicesStatus.deserialize(bytes); + } + } } diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 3956e27..38b5dd2 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -24,7 +24,7 @@ export namespace graphicData { separators?: Separator[]; sectionLinks?: SectionLink[]; axleCountingSections?: AxleCountingSection[]; - logicSections?: AxleCountingSection[]; + 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); @@ -182,9 +182,9 @@ export namespace graphicData { pb_1.Message.setRepeatedWrapperField(this, 16, value); } get logicSections() { - return pb_1.Message.getRepeatedWrapperField(this, AxleCountingSection, 17) as AxleCountingSection[]; + return pb_1.Message.getRepeatedWrapperField(this, LogicSection, 17) as LogicSection[]; } - set logicSections(value: AxleCountingSection[]) { + set logicSections(value: LogicSection[]) { pb_1.Message.setRepeatedWrapperField(this, 17, value); } static fromObject(data: { @@ -204,7 +204,7 @@ export namespace graphicData { separators?: ReturnType[]; sectionLinks?: ReturnType[]; axleCountingSections?: ReturnType[]; - logicSections?: ReturnType[]; + logicSections?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -256,7 +256,7 @@ export namespace graphicData { message.axleCountingSections = data.axleCountingSections.map(item => AxleCountingSection.fromObject(item)); } if (data.logicSections != null) { - message.logicSections = data.logicSections.map(item => AxleCountingSection.fromObject(item)); + message.logicSections = data.logicSections.map(item => LogicSection.fromObject(item)); } return message; } @@ -278,7 +278,7 @@ export namespace graphicData { separators?: ReturnType[]; sectionLinks?: ReturnType[]; axleCountingSections?: ReturnType[]; - logicSections?: ReturnType[]; + logicSections?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -329,7 +329,7 @@ export namespace graphicData { data.axleCountingSections = this.axleCountingSections.map((item: AxleCountingSection) => item.toObject()); } if (this.logicSections != null) { - data.logicSections = this.logicSections.map((item: AxleCountingSection) => item.toObject()); + data.logicSections = this.logicSections.map((item: LogicSection) => item.toObject()); } return data; } @@ -370,7 +370,7 @@ export namespace graphicData { if (this.axleCountingSections.length) writer.writeRepeatedMessage(16, this.axleCountingSections, (item: AxleCountingSection) => item.serialize(writer)); if (this.logicSections.length) - writer.writeRepeatedMessage(17, this.logicSections, (item: AxleCountingSection) => item.serialize(writer)); + writer.writeRepeatedMessage(17, this.logicSections, (item: LogicSection) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -429,7 +429,7 @@ export namespace graphicData { reader.readMessage(message.axleCountingSections, () => pb_1.Message.addToRepeatedWrapperField(message, 16, AxleCountingSection.deserialize(reader), AxleCountingSection)); break; case 17: - reader.readMessage(message.logicSections, () => pb_1.Message.addToRepeatedWrapperField(message, 17, AxleCountingSection.deserialize(reader), AxleCountingSection)); + reader.readMessage(message.logicSections, () => pb_1.Message.addToRepeatedWrapperField(message, 17, LogicSection.deserialize(reader), LogicSection)); break; default: reader.skipField(); } @@ -3941,4 +3941,166 @@ export namespace graphicData { return AxleCountingSection.deserialize(bytes); } } + export class LogicSection extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + common?: CommonInfo; + code?: string; + points?: Point[]; + axleSectionId?: string; + indexNumber?: number; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], 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 ("points" in data && data.points != undefined) { + this.points = data.points; + } + if ("axleSectionId" in data && data.axleSectionId != undefined) { + this.axleSectionId = data.axleSectionId; + } + if ("indexNumber" in data && data.indexNumber != undefined) { + this.indexNumber = data.indexNumber; + } + } + } + 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 points() { + return pb_1.Message.getRepeatedWrapperField(this, Point, 3) as Point[]; + } + set points(value: Point[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); + } + get axleSectionId() { + return pb_1.Message.getFieldWithDefault(this, 4, "") as string; + } + set axleSectionId(value: string) { + pb_1.Message.setField(this, 4, value); + } + get indexNumber() { + return pb_1.Message.getFieldWithDefault(this, 5, 0) as number; + } + set indexNumber(value: number) { + pb_1.Message.setField(this, 5, value); + } + static fromObject(data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + axleSectionId?: string; + indexNumber?: number; + }): LogicSection { + const message = new LogicSection({}); + if (data.common != null) { + message.common = CommonInfo.fromObject(data.common); + } + if (data.code != null) { + message.code = data.code; + } + if (data.points != null) { + message.points = data.points.map(item => Point.fromObject(item)); + } + if (data.axleSectionId != null) { + message.axleSectionId = data.axleSectionId; + } + if (data.indexNumber != null) { + message.indexNumber = data.indexNumber; + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + axleSectionId?: string; + indexNumber?: number; + } = {}; + if (this.common != null) { + data.common = this.common.toObject(); + } + if (this.code != null) { + data.code = this.code; + } + if (this.points != null) { + data.points = this.points.map((item: Point) => item.toObject()); + } + if (this.axleSectionId != null) { + data.axleSectionId = this.axleSectionId; + } + if (this.indexNumber != null) { + data.indexNumber = this.indexNumber; + } + 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.points.length) + writer.writeRepeatedMessage(3, this.points, (item: Point) => item.serialize(writer)); + if (this.axleSectionId.length) + writer.writeString(4, this.axleSectionId); + if (this.indexNumber != 0) + writer.writeInt32(5, this.indexNumber); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): LogicSection { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new LogicSection(); + 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: + reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Point.deserialize(reader), Point)); + break; + case 4: + message.axleSectionId = reader.readString(); + break; + case 5: + message.indexNumber = reader.readInt32(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): LogicSection { + return LogicSection.deserialize(bytes); + } + } } From d4bc0f6648f3a4781bab95e471564d09fab946f2 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Tue, 11 Jul 2023 17:09:49 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E6=8B=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AxleCountingSectionAssistant.ts | 107 +++++++++++++++++- 1 file changed, 102 insertions(+), 5 deletions(-) diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index c6a8e56..c33b63a 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -1,4 +1,11 @@ -import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js'; +import { + DisplayObject, + FederatedMouseEvent, + FederatedPointerEvent, + IHitArea, + IPointData, + Point, +} from 'pixi.js'; import { GraphicDrawAssistant, GraphicIdGenerator, @@ -6,6 +13,7 @@ import { JlDrawApp, JlGraphic, linePoint, + splitLineEvenly, } from 'src/jl-graphic'; import { @@ -18,6 +26,13 @@ import { import { AxleCounting } from '../axleCounting/AxleCounting'; import { Turnout } from '../turnout/Turnout'; import { createRelatedRefProto } from '../CommonGraphics'; +import { MenuItemOptions } from 'src/jl-graphic/ui/Menu'; +import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; +import { Dialog } from 'quasar'; +import { LogicSection } from '../logicSection/LogicSection'; +import { LogicSectionData } from 'src/drawApp/graphics/LogicSectionInteraction'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import SectionSplitDialog from 'src/components/draw-app/dialogs/SectionSplitDialog.vue'; function hasCommonElements(arr1: string[], arr2: string[]) { for (let i = 0; i < arr1.length; i++) { @@ -51,7 +66,7 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< super(app, template, 'sym_o_circle', '不展示'); this.codeGraph = this.graphicTemplate.new(); this.container.addChild(this.codeGraph); - AxleCountingSectionInteraction.init(app); + AxleCountingSectionInteraction.init(app, this); } bind(): void { @@ -274,13 +289,28 @@ class AxleCountingSectionGraphicHitArea implements IHitArea { } } +export const splitSectionConfig: MenuItemOptions = { + name: '拆分计轴区段', +}; +const SectionEditMenu: ContextMenu = ContextMenu.init({ + name: '区段编辑菜单', + groups: [ + { + items: [splitSectionConfig], + }, + ], +}); + export class AxleCountingSectionInteraction extends GraphicInteractionPlugin { static Name = 'AxleCountingSection_transform'; - constructor(app: JlDrawApp) { + drawAssistant: AxleCountingSectionDraw; + constructor(app: JlDrawApp, da: AxleCountingSectionDraw) { super(AxleCountingSectionInteraction.Name, app); + this.drawAssistant = da; + app.registerMenu(SectionEditMenu); } - static init(app: JlDrawApp) { - return new AxleCountingSectionInteraction(app); + static init(app: JlDrawApp, da: AxleCountingSectionDraw) { + return new AxleCountingSectionInteraction(app, da); } filter(...grahpics: JlGraphic[]): AxleCountingSection[] | undefined { return grahpics @@ -299,6 +329,7 @@ export class AxleCountingSectionInteraction extends GraphicInteractionPlugin { + Dialog.create({ + title: '拆分逻辑区段', + message: '请选择生成数量和方向', + component: SectionSplitDialog, + cancel: true, + persistent: true, + }).onOk((data: { num: number; dir: 'ltr' | 'rtl' }) => { + const logicSections = this.app.queryStore.queryByType( + LogicSection.Type + ); + logicSections.forEach((logicSection) => { + if (logicSection.datas.axleSectionId == axleCountingSection.id) { + this.app.deleteGraphics(logicSection); + } + }); + const { num, dir } = data; + const axleCountingSectionData = axleCountingSection.datas; + const points = splitLineEvenly( + axleCountingSection.localToCanvasPoint( + axleCountingSectionData.points[0] + ), + axleCountingSection.localToCanvasPoint( + axleCountingSectionData.points[ + axleCountingSectionData.points.length - 1 + ] + ), + num + ); + // let codeAppend = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.slice(0, num); + if ( + (dir === 'ltr' && + axleCountingSectionData.points[0].x > + axleCountingSectionData.points[ + axleCountingSectionData.points.length - 1 + ].x) || + (dir === 'rtl' && + axleCountingSectionData.points[0].x < + axleCountingSectionData.points[ + axleCountingSectionData.points.length - 1 + ].x) + ) { + // codeAppend = codeAppend.split('').reverse().join(''); + } + points.forEach((ps, i) => { + const data = new LogicSectionData(); + data.id = GraphicIdGenerator.next(); + data.axleSectionId = axleCountingSection.id; + // data.code = `${codeAppend.charAt(i % 26)}`; + data.points = ps.map( + (p) => new graphicData.Point({ x: p.x, y: p.y }) + ); + const g = new LogicSection(); + g.loadData(data); + this.drawAssistant.storeGraphic(g); + }); + }); + }; + SectionEditMenu.open(e.global); } } From dbd01d71a312059f2284b90e5b8190d132f2a636 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Tue, 11 Jul 2023 17:35:11 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logicSection/LogicSectionDrawAssistant.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/graphics/logicSection/LogicSectionDrawAssistant.ts b/src/graphics/logicSection/LogicSectionDrawAssistant.ts index 489d767..b7b1492 100644 --- a/src/graphics/logicSection/LogicSectionDrawAssistant.ts +++ b/src/graphics/logicSection/LogicSectionDrawAssistant.ts @@ -78,13 +78,11 @@ export class LogicSectionDraw extends GraphicDrawAssistant< AxleCountingSection.Type ); axleCountingSections.forEach((axleCountingSection) => { - if (map.has(`${axleCountingSection.id}`)) { - return; - } const turnoutPosRef = axleCountingSection.datas.turnoutPosRef; if (turnoutPosRef.length > 0) { turnoutPosRef.forEach((turnout) => { - if (turnout.position == 1) { + if (turnout.position == 1 && !map.has(`${turnout.id}`)) { + map.set(`${turnout.id}`, 1); const t = this.app.queryStore.queryById(turnout.id) as Turnout; const data = new LogicSectionData(); data.points = [ @@ -96,10 +94,13 @@ export class LogicSectionDraw extends GraphicDrawAssistant< } }); } - const data = new LogicSectionData(); - data.points = axleCountingSection.datas.points; - data.axleSectionId = axleCountingSection.id; - this.draw(data); + if (!map.has(`${axleCountingSection.id}`)) { + map.set(`${axleCountingSection.id}`, 1); + const data = new LogicSectionData(); + data.points = axleCountingSection.datas.points; + data.axleSectionId = axleCountingSection.id; + this.draw(data); + } }); } } From e73fe0ede652cf2615f1be3b4d3bc5496f50c53e Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Tue, 11 Jul 2023 17:42:04 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E5=A2=9E=E9=87=8F=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AxleCountingSectionAssistant.ts | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index c33b63a..6d9e64e 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -93,8 +93,14 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< draw( graphics: AxleCounting[], commonElement: JlGraphic[], + map: Map, turoutPos?: number ) { + if ( + map.has(`${graphics[0].id}+${graphics[1].id}`) || + map.has(`${graphics[1].id}+${graphics[0].id}`) + ) + return; const axleCountingSection = new AxleCountingSection(); axleCountingSection.loadData(this.graphicTemplate.datas); axleCountingSection.datas.points = [ @@ -135,11 +141,17 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< } oneGenerates() { + const map = new Map(); const axleCountingSections = this.app.queryStore.queryByType( AxleCountingSection.Type ); - this.app.deleteGraphics(...axleCountingSections); + axleCountingSections.forEach((axleCountingSection) => { + map.set( + `${axleCountingSection.datas.paRef?.id}+${axleCountingSection.datas.pbRef?.id}`, + 1 + ); + }); const axleCountings = this.app.queryStore.queryByType( AxleCounting.Type ); @@ -185,6 +197,7 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< this.draw( [axleCounting, axleCountings[i]], [commonElement], + map, turoutPos ); } @@ -244,7 +257,8 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< ) { this.draw( [fourAxleCounting[x].axleCounting, AxleCountings[y].axleCounting], - [fourAxleCounting[x].refTurout, AxleCountings[y].refTurout] + [fourAxleCounting[x].refTurout, AxleCountings[y].refTurout], + map ); break; } @@ -264,7 +278,8 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< fourAxleCounting[x + 1].axleCounting, AxleCountings[y].axleCounting, ], - [fourAxleCounting[x + 1].refTurout, AxleCountings[y].refTurout] + [fourAxleCounting[x + 1].refTurout, AxleCountings[y].refTurout], + map ); break; } From bc0844523bf71272caf36d4793a815f2d918ac78 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Wed, 12 Jul 2023 10:12:15 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=92=8C=E8=AE=A1?= =?UTF-8?q?=E8=BD=B4=E5=8C=BA=E6=AE=B5=E7=9A=84code=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/properties/AxleCountingSectionProperty.vue | 4 ++-- src/graphics/axleCounting/AxleCountingDrawAssistant.ts | 2 +- src/graphics/axleCountingSection/AxleCountingSection.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/draw-app/properties/AxleCountingSectionProperty.vue b/src/components/draw-app/properties/AxleCountingSectionProperty.vue index d4bd857..f1657c9 100644 --- a/src/components/draw-app/properties/AxleCountingSectionProperty.vue +++ b/src/components/draw-app/properties/AxleCountingSectionProperty.vue @@ -75,7 +75,7 @@ const drawStore = useDrawStore(); const axleCountingSectionModel = reactive(new AxleCountingSectionData()); enum turoutPos { - '正位', + '定位', '反位', } @@ -133,7 +133,7 @@ const turnoutRelations = computed(() => { refTurnoutAndPos.push({ turnout: refTurout, pos: ref.position }); }); const ref = refTurnoutAndPos.map( - (ref) => `${ref.turnout.datas.code}+${turoutPos[ref.pos]}` + (ref) => `${ref.turnout.datas.code}:${turoutPos[ref.pos]}` ); return Array.from(new Set(ref)); }); diff --git a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts index 85ec97b..7ac26b5 100644 --- a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts +++ b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts @@ -118,7 +118,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant< } axleCounting.id = GraphicIdGenerator.next(); axleCounting.datas.axleCountingRef = [refData2, refData1]; - axleCounting.datas.code = `${graphic.datas.code}-${port}+${refGraphic.datas.code}-${refPort}`; + axleCounting.datas.code = `${graphic.datas.code}-${port}\\${refGraphic.datas.code}-${refPort}`; this.storeGraphic(axleCounting); axleCounting.loadRelations(); } diff --git a/src/graphics/axleCountingSection/AxleCountingSection.ts b/src/graphics/axleCountingSection/AxleCountingSection.ts index c2e36a0..cc765e0 100644 --- a/src/graphics/axleCountingSection/AxleCountingSection.ts +++ b/src/graphics/axleCountingSection/AxleCountingSection.ts @@ -25,7 +25,7 @@ export interface IAxleCountingSectionData extends GraphicData { set paRef(ref: IRelatedRefData | undefined); get pbRef(): IRelatedRefData | undefined; //区段B端关联的设备 set pbRef(ref: IRelatedRefData | undefined); - get turnoutPosRef(): ITurnoutPosRefData[]; //关联道岔的正反位 + get turnoutPosRef(): ITurnoutPosRefData[]; //关联道岔的定反位--0是定位,1是反位 set turnoutPosRef(ref: ITurnoutPosRefData[]); get indexNumber(): number; // 索引编号 set indexNumber(v: number); From 37d73efc9d095d757845ed6f1ad72aaa1ef6af5f Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 12 Jul 2023 10:26:07 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/properties/LogicSectionProperty.vue | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/components/draw-app/properties/LogicSectionProperty.vue b/src/components/draw-app/properties/LogicSectionProperty.vue index 93c9545..8c51724 100644 --- a/src/components/draw-app/properties/LogicSectionProperty.vue +++ b/src/components/draw-app/properties/LogicSectionProperty.vue @@ -84,15 +84,9 @@ function onUpdate() { const logicSectionRelations = computed(() => { const logicSection = drawStore.selectedGraphic as LogicSection; - const sectionRelations = - logicSection?.relationManage.getRelationsOfGraphicAndOtherType( - logicSection, - AxleCountingSection.Type - ); - const ref = sectionRelations.map( - (relation) => - `${relation.getOtherGraphic(logicSection).datas.code}` - ); - return Array.from(new Set(ref)); + const axleCountingSection = logicSection.queryStore.queryById( + logicSection.datas.axleSectionId + ) as AxleCountingSection; + return [axleCountingSection.datas.code]; }); From 4427c5141009edeba864f365eff375a296137d74 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Wed, 12 Jul 2023 10:41:28 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB=E7=AE=A1=E7=90=86=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=81=93=E5=B2=94=E4=BD=8D=E7=BD=AE=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../axleCountingSection/AxleCountingSection.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/graphics/axleCountingSection/AxleCountingSection.ts b/src/graphics/axleCountingSection/AxleCountingSection.ts index cc765e0..3918ce5 100644 --- a/src/graphics/axleCountingSection/AxleCountingSection.ts +++ b/src/graphics/axleCountingSection/AxleCountingSection.ts @@ -116,6 +116,17 @@ export class AxleCountingSection extends JlGraphic { ) ); } + if (this.datas?.turnoutPosRef.length) { + this.datas.turnoutPosRef.forEach((ref) => { + this.relationManage.addRelation( + this, + new GraphicRelationParam( + this.queryStore.queryById(ref.id), + ref.position + ) + ); + }); + } } } From de6b1a70cc2f67a78a32ee592ae7bf6b78ec2117 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 12 Jul 2023 10:51:06 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jl-graphic/app/JlDrawApp.ts | 14 +++++++------- src/jl-graphic/app/JlGraphicApp.ts | 20 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/jl-graphic/app/JlDrawApp.ts b/src/jl-graphic/app/JlDrawApp.ts index 8a1bfa2..79f1071 100644 --- a/src/jl-graphic/app/JlDrawApp.ts +++ b/src/jl-graphic/app/JlDrawApp.ts @@ -456,13 +456,13 @@ export class JlDrawApp extends GraphicApp { * 删除选中图形对象 */ deleteSelectedGraphics() { - const deletes = this.selectedGraphics.slice( - 0, - this.selectedGraphics.length - ); - this.deleteGraphics(...this.selectedGraphics); - // 删除图形对象操作记录 - this.opRecord.record(new GraphicDeleteOperation(this, deletes)); + const deletes = this.deleteGraphics(...this.selectedGraphics); + if (deletes.length > 0) { + // 删除图形对象操作记录 + this.opRecord.record(new GraphicDeleteOperation(this, deletes)); + } else { + console.debug('没有删除元素,不记录'); + } } updateCanvasAndRecord(data: ICanvasProperties) { diff --git a/src/jl-graphic/app/JlGraphicApp.ts b/src/jl-graphic/app/JlGraphicApp.ts index e073582..4be56ea 100644 --- a/src/jl-graphic/app/JlGraphicApp.ts +++ b/src/jl-graphic/app/JlGraphicApp.ts @@ -320,6 +320,11 @@ export interface IGraphicAppConfig { * 超出屏幕显示范围是否剪裁,默认true */ cullable?: boolean; + + /** + * 是否支持删除操作 + */ + isSupportDeletion?: (g: JlGraphic) => boolean; } /** @@ -729,8 +734,19 @@ export class GraphicApp extends EventEmitter { * 删除图形 * @param graphics 图形对象 */ - deleteGraphics(...graphics: JlGraphic[]) { - graphics.forEach((g) => this.doDeleteGraphics(g)); + deleteGraphics(...graphics: JlGraphic[]): JlGraphic[] { + const dels = graphics.filter((g) => { + if ( + this._options?.isSupportDeletion && + this._options.isSupportDeletion(g) + ) { + this.doDeleteGraphics(g); + return true; + } + console.debug(`type=${g.type},id=${g.id}的图形不支持删除`); + return false; + }); + return dels; } /** From fa599de542a4915e350db59fa50d6ac76fda938c Mon Sep 17 00:00:00 2001 From: Yuan Date: Wed, 12 Jul 2023 11:23:22 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E7=89=A9=E7=90=86=E5=8C=BA=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bj-rtss-message | 2 +- graphic-pixi | 2 +- .../draw-app/properties/SectionProperty.vue | 83 +++- src/drawApp/graphics/SectionInteraction.ts | 14 +- src/graphics/section/Section.ts | 114 ++--- src/graphics/section/SectionDrawAssistant.ts | 225 ++++++---- src/graphics/turnout/Turnout.ts | 12 + src/jl-graphic/app/JlDrawApp.ts | 14 +- src/jl-graphic/app/JlGraphicApp.ts | 20 +- src/layouts/DrawLayout.vue | 14 +- src/protos/device_state.ts | 249 +++++++++++ src/protos/stationLayoutGraphics.ts | 398 +++++++++++++++++- 12 files changed, 981 insertions(+), 166 deletions(-) diff --git a/bj-rtss-message b/bj-rtss-message index f6f49ec..2a1a715 160000 --- a/bj-rtss-message +++ b/bj-rtss-message @@ -1 +1 @@ -Subproject commit f6f49ec19378c9a9845c53bd4425143f654ae59e +Subproject commit 2a1a7156c02ee902b1801f022ffd8aa6b763c66b diff --git a/graphic-pixi b/graphic-pixi index a7debf1..f89c8eb 160000 --- a/graphic-pixi +++ b/graphic-pixi @@ -1 +1 @@ -Subproject commit a7debf165e24e6200d7c986555f31c721792af38 +Subproject commit f89c8eb48de7b2e39a93c4aab9b4e5ff1a9e91b4 diff --git a/src/components/draw-app/properties/SectionProperty.vue b/src/components/draw-app/properties/SectionProperty.vue index 18eed7c..048aa1e 100644 --- a/src/components/draw-app/properties/SectionProperty.vue +++ b/src/components/draw-app/properties/SectionProperty.vue @@ -3,11 +3,35 @@ + - + + - + + + +