From e7fbcc3e3b99e6cca280d8938a8d76d113ab1928 Mon Sep 17 00:00:00 2001 From: fan Date: Wed, 12 Jul 2023 13:05:42 +0800 Subject: [PATCH 1/9] =?UTF-8?q?sectionLInk=E9=80=BB=E8=BE=91=E5=85=B3?= =?UTF-8?q?=E7=B3=BB=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bj-rtss-message | 2 +- .../properties/SectionLinkProperty.vue | 94 ++- .../graphics/SectionLinkInteraction.ts | 32 +- src/drawApp/index.ts | 6 +- src/graphics/CommonGraphics.ts | 5 + src/graphics/sectionLink/SectionLink.ts | 13 +- .../sectionLink/SectionLinkDrawAssistant.ts | 244 ++++++- src/protos/device_state.ts | 249 +++++++ src/protos/stationLayoutGraphics.ts | 624 ++++++++++++++++-- 9 files changed, 1207 insertions(+), 62 deletions(-) diff --git a/bj-rtss-message b/bj-rtss-message index f6f49ec..f0f4152 160000 --- a/bj-rtss-message +++ b/bj-rtss-message @@ -1 +1 @@ -Subproject commit f6f49ec19378c9a9845c53bd4425143f654ae59e +Subproject commit f0f415273f5e188db87ee361e6808e4ec90ceda1 diff --git a/src/components/draw-app/properties/SectionLinkProperty.vue b/src/components/draw-app/properties/SectionLinkProperty.vue index 1052c01..b3215bc 100644 --- a/src/components/draw-app/properties/SectionLinkProperty.vue +++ b/src/components/draw-app/properties/SectionLinkProperty.vue @@ -13,6 +13,53 @@ @blur="onUpdate" label="编号" /> + + + + + A端关联设备 +
+ + {{ aSimRef }} + +
+
+
+ + + B端关联设备 +
+ + {{ bSimRef }} + +
+
+
+ + + A端关联端口设备 +
+ + {{ aRef }} + +
+
+
+ + + B端关联端口设备 +
+ + {{ bRef }} + +
+
+
+
@@ -20,16 +67,61 @@ import { SectionLink } from 'src/graphics/sectionLink/SectionLink'; import { SectionLinkData } from 'src/drawApp/graphics/SectionLinkInteraction'; import { useDrawStore } from 'src/stores/draw-store'; -import { shallowRef, watchEffect } from 'vue'; +import { shallowRef, watchEffect, ref } from 'vue'; +import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; +import { Turnout } from 'src/graphics/turnout/Turnout'; const drawStore = useDrawStore(); const sectionLinkModel = shallowRef(new SectionLinkData()); +const aSimRef = ref(''); +const bSimRef = ref(''); +const aRef = ref(''); +const bRef = ref(''); watchEffect(() => { const sectionLink = drawStore.selectedGraphic; + const portList = ['A', 'B', 'C']; if (sectionLink && sectionLink instanceof SectionLink) { sectionLinkModel.value = sectionLink.saveData(); + aSimRef.value = ''; + bSimRef.value = ''; + aRef.value = ''; + bRef.value = ''; + if (sectionLinkModel.value.aSimRef) { + const g = drawStore + .getDrawApp() + .queryStore.queryById(sectionLinkModel.value.aSimRef.id) as + | AxleCounting + | Turnout; + aSimRef.value = g.datas.code; + } + if (sectionLinkModel.value.bSimRef) { + const g = drawStore + .getDrawApp() + .queryStore.queryById(sectionLinkModel.value.bSimRef.id) as + | AxleCounting + | Turnout; + bSimRef.value = g.datas.code; + } + if (sectionLinkModel.value.aRef) { + const g = drawStore + .getDrawApp() + .queryStore.queryById(sectionLinkModel.value.aRef.id) as + | SectionLink + | Turnout; + aRef.value = + g.datas.code + '_' + portList[sectionLinkModel.value.aRef.devicePort]; + } + if (sectionLinkModel.value.bRef) { + const g = drawStore + .getDrawApp() + .queryStore.queryById(sectionLinkModel.value.bRef.id) as + | SectionLink + | Turnout; + bRef.value = + g.datas.code + '_' + portList[sectionLinkModel.value.bRef.devicePort]; + } } }); diff --git a/src/drawApp/graphics/SectionLinkInteraction.ts b/src/drawApp/graphics/SectionLinkInteraction.ts index c7d0d38..346bc50 100644 --- a/src/drawApp/graphics/SectionLinkInteraction.ts +++ b/src/drawApp/graphics/SectionLinkInteraction.ts @@ -39,11 +39,35 @@ export class SectionLinkData (p) => new graphicData.Point({ x: p.x, y: p.y }) ); } - get refDevice(): string { - return this.data.refDevice; + get up(): boolean { + return this.data.up; } - set refDevice(v: string) { - this.data.refDevice = v; + set up(v: boolean) { + this.data.up = v; + } + get aSimRef(): graphicData.SimpleRef { + return this.data.aSimRef; + } + set aSimRef(v: graphicData.SimpleRef) { + this.data.aSimRef = v; + } + get bSimRef(): graphicData.SimpleRef { + return this.data.bSimRef; + } + set bSimRef(v: graphicData.SimpleRef) { + this.data.bSimRef = v; + } + get aRef(): graphicData.RelatedRef { + return this.data.aRef; + } + set aRef(v: graphicData.RelatedRef) { + this.data.aRef = v; + } + get bRef(): graphicData.RelatedRef { + return this.data.bRef; + } + set bRef(v: graphicData.RelatedRef) { + this.data.bRef = v; } clone(): SectionLinkData { diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 6a3576c..13db706 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -446,9 +446,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.axleCountingSections.forEach((axleCountingSection) => { datas.push(new AxleCountingSectionData(axleCountingSection)); }); - storage.logicSections.forEach((logicSection) => { - datas.push(new LogicSectionData(logicSection)); - }); + // storage.logicSections.forEach((logicSection) => { + // datas.push(new LogicSectionData(logicSection)); + // }); await app.loadGraphic(datas); } else { app.loadGraphic([]); diff --git a/src/graphics/CommonGraphics.ts b/src/graphics/CommonGraphics.ts index 58777ff..8f1ffcf 100644 --- a/src/graphics/CommonGraphics.ts +++ b/src/graphics/CommonGraphics.ts @@ -114,3 +114,8 @@ export interface IRelatedRefData { id: string; //关联的设备ID devicePort: graphicData.RelatedRef.DevicePort; //关联的设备端口 } + +export interface ISimpleRefData { + deviceType: graphicData.SimpleRef.DeviceType; + id: string; +} diff --git a/src/graphics/sectionLink/SectionLink.ts b/src/graphics/sectionLink/SectionLink.ts index f085f74..e1f9479 100644 --- a/src/graphics/sectionLink/SectionLink.ts +++ b/src/graphics/sectionLink/SectionLink.ts @@ -9,14 +9,23 @@ import { movePointAlongNormal, } from 'src/jl-graphic'; import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin'; +import { IRelatedRefData, ISimpleRefData } from '../CommonGraphics'; export interface ISectionLinkData extends GraphicData { get code(): string; // 编号 set code(v: string); get points(): IPointData[]; set points(points: IPointData[]); - get refDevice(): string; - set refDevice(v: string); + get up(): boolean; + set up(v: boolean); + get aSimRef(): ISimpleRefData; + set aSimRef(v: ISimpleRefData); + get bSimRef(): ISimpleRefData; + set bSimRef(v: ISimpleRefData); + get aRef(): IRelatedRefData; + set aRef(v: IRelatedRefData); + get bRef(): IRelatedRefData; + set bRef(v: IRelatedRefData); clone(): ISectionLinkData; copyFrom(data: ISectionLinkData): void; eq(other: ISectionLinkData): boolean; diff --git a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts index 626b759..b5f67aa 100644 --- a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts +++ b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts @@ -25,6 +25,7 @@ import { Section } from '../section/Section'; import { Turnout } from '../turnout/Turnout'; import { AxleCounting } from '../axleCounting/AxleCounting'; import { IRelatedRefData } from '../CommonGraphics'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; export class SectionLinkDraw extends GraphicDrawAssistant< SectionLinkTemplate, @@ -59,15 +60,18 @@ export class SectionLinkDraw extends GraphicDrawAssistant< } }); this.graphic.lineTo(cp.x, cp.y); - console.log(cp, '000'); } prepareData(data: ISectionLinkData): boolean { - console.log(this.points, '000'); data.points = this.points; return true; } - generateBySection(section: Section) { + generateBySection( + section: Section, + refData: IRelatedRefData, + axle1: AxleCounting, + axle2: AxleCounting + ): SectionLink { const sectionLink = new SectionLink(); sectionLink.loadData(this.graphicTemplate.datas); sectionLink.id = GraphicIdGenerator.next(); @@ -76,14 +80,57 @@ export class SectionLinkDraw extends GraphicDrawAssistant< points.push(section.localToCanvasPoint(p)); }); sectionLink.datas.points = points; + const DeviceType = graphicData.SimpleRef.DeviceType; + const refAxle1 = this.buildSimpleRef(axle1.id, DeviceType.AxleCounting); + const refAxle2 = this.buildSimpleRef(axle2.id, DeviceType.AxleCounting); + /** + * 判断link AB端 A端一定在左侧(根据计轴关联区段判断区段AB端是否倒序) + */ + if (points[0].x > points[points.length - 1].x) { + if (refData.devicePort === 0) { + sectionLink.datas.aSimRef = refAxle2; + sectionLink.datas.bSimRef = refAxle1; + } else { + sectionLink.datas.aSimRef = refAxle1; + sectionLink.datas.bSimRef = refAxle2; + } + } else if (points[0].x < points[points.length - 1].x) { + if (refData.devicePort === 0) { + sectionLink.datas.aSimRef = refAxle1; + sectionLink.datas.bSimRef = refAxle2; + } else { + sectionLink.datas.aSimRef = refAxle2; + sectionLink.datas.bSimRef = refAxle1; + } + } else { + throw new Error('无法判断linkAB端'); + } this.storeGraphic(sectionLink); + return sectionLink; } - generateByTurnoutAxle(turnout: Turnout, port: number) { + generateByTurnoutAxle( + turnout: Turnout, + port: graphicData.RelatedRef.DevicePort, + axle: AxleCounting + ): SectionLink { const sectionLink = new SectionLink(); sectionLink.loadData(this.graphicTemplate.datas); sectionLink.id = GraphicIdGenerator.next(); const forkP = new Point(turnout.position.x, turnout.position.y); const points: IPointData[] = [forkP]; + const refTurnout = this.buildRelatedRef( + turnout.id, + graphicData.RelatedRef.DeviceType.Turnout, + port + ); + const refSimTurnout = this.buildSimpleRef( + turnout.id, + graphicData.SimpleRef.DeviceType.Turnout + ); + const refAxle = this.buildSimpleRef( + axle.id, + graphicData.SimpleRef.DeviceType.AxleCounting + ); if (port === 0) { turnout.datas.pointA.forEach((p) => { points.push(turnout.localToCanvasPoint(p)); @@ -97,10 +144,26 @@ export class SectionLinkDraw extends GraphicDrawAssistant< points.push(turnout.localToCanvasPoint(p)); }); } + if (points[0].x > points[points.length - 1].x) { + sectionLink.datas.aSimRef = refAxle; + sectionLink.datas.bSimRef = refSimTurnout; + sectionLink.datas.bRef = refTurnout; + } else if (points[0].x < points[points.length - 1].x) { + sectionLink.datas.bSimRef = refAxle; + sectionLink.datas.aSimRef = refSimTurnout; + sectionLink.datas.aRef = refTurnout; + } else { + throw new Error('无法判断linkAB端'); + } sectionLink.datas.points = points; this.storeGraphic(sectionLink); + return sectionLink; } - generateByTurnout(turnout: Turnout, port: number, pRef: IRelatedRefData) { + generateByTurnout( + turnout: Turnout, + port: graphicData.RelatedRef.DevicePort, + pRef: IRelatedRefData + ) { const refg = this.app.queryStore.queryById(pRef.id) as Turnout; const sectionLink = new SectionLink(); sectionLink.loadData(this.graphicTemplate.datas); @@ -108,6 +171,37 @@ export class SectionLinkDraw extends GraphicDrawAssistant< const forkP1 = new Point(refg.position.x, refg.position.y); const forkP2 = new Point(turnout.position.x, turnout.position.y); const points: IPointData[] = [forkP1]; + const refTurnout1 = this.buildRelatedRef( + turnout.id, + graphicData.RelatedRef.DeviceType.Turnout, + port + ); + const refTurnout2 = this.buildRelatedRef( + pRef.id, + graphicData.RelatedRef.DeviceType.Turnout, + pRef.devicePort + ); + const refSimT1 = this.buildSimpleRef( + turnout.id, + graphicData.SimpleRef.DeviceType.Turnout + ); + const refSimT2 = this.buildSimpleRef( + pRef.id, + graphicData.SimpleRef.DeviceType.Turnout + ); + if (forkP1.x > forkP2.x) { + sectionLink.datas.aSimRef = refSimT2; + sectionLink.datas.bSimRef = refSimT1; + sectionLink.datas.aRef = refTurnout2; + sectionLink.datas.bRef = refTurnout1; + } else if (forkP1.x < forkP2.x) { + sectionLink.datas.aSimRef = refSimT1; + sectionLink.datas.bSimRef = refSimT2; + sectionLink.datas.aRef = refTurnout1; + sectionLink.datas.bRef = refTurnout2; + } else { + throw new Error('无法判断linkAB端'); + } if (pRef.devicePort === 0) { refg.datas.pointA.forEach((p) => { points.push(refg.localToCanvasPoint(p)); @@ -137,28 +231,154 @@ export class SectionLinkDraw extends GraphicDrawAssistant< sectionLink.datas.points = points; this.storeGraphic(sectionLink); } + /** + * 缓存计轴和link关系,为生成link关联关系提供数据依据 + * @param map + * @param axleId + * @param linkId + */ + cacheAxleLinkRelation( + map: Map, + axleId: string, + linkId: string + ) { + const list = map.get(axleId); + if (list) { + list.push(linkId); + map.set(axleId, list); + } else { + map.set(axleId, [linkId]); + } + } + /** + * 构建简单设备关联数据 + * @param id + * @param deviceType + * @returns + */ + buildSimpleRef(id: string, deviceType: graphicData.SimpleRef.DeviceType) { + return new graphicData.SimpleRef({ deviceType, id }); + } + /** + * 构建关系数据 + * @param id + * @param deviceType + * @param devicePort + * @returns + */ + buildRelatedRef( + id: string, + deviceType: graphicData.RelatedRef.DeviceType, + devicePort: graphicData.RelatedRef.DevicePort + ): IRelatedRefData { + return new graphicData.RelatedRef({ id, deviceType, devicePort }); + } + /**构建link之间的关联关系 */ + buildLinkRef(map: Map) { + const DeviceType = graphicData.RelatedRef.DeviceType; + const DevicePort = graphicData.RelatedRef.DevicePort; + map.forEach((value) => { + if (value.length === 2) { + const link1 = this.app.queryStore.queryById(value[0]) as SectionLink; + const link2 = this.app.queryStore.queryById(value[1]) as SectionLink; + if (link1.datas.aSimRef.id === link2.datas.bSimRef.id) { + link1.datas.aRef = this.buildRelatedRef( + link2.id, + DeviceType.SectionLink, + DevicePort.B + ); + link2.datas.bRef = this.buildRelatedRef( + link1.id, + DeviceType.SectionLink, + DevicePort.A + ); + } else if (link1.datas.bSimRef.id === link2.datas.aSimRef.id) { + link1.datas.bRef = this.buildRelatedRef( + link2.id, + DeviceType.SectionLink, + DevicePort.A + ); + link2.datas.aRef = this.buildRelatedRef( + link1.id, + DeviceType.SectionLink, + DevicePort.B + ); + } else if (link1.datas.aSimRef.id === link2.datas.aSimRef.id) { + link1.datas.aRef = this.buildRelatedRef( + link2.id, + DeviceType.SectionLink, + DevicePort.A + ); + link2.datas.aRef = this.buildRelatedRef( + link1.id, + DeviceType.SectionLink, + DevicePort.A + ); + } else if (link1.datas.bSimRef.id === link2.datas.bSimRef.id) { + link1.datas.bRef = this.buildRelatedRef( + link2.id, + DeviceType.SectionLink, + DevicePort.B + ); + link2.datas.bRef = this.buildRelatedRef( + link1.id, + DeviceType.SectionLink, + DevicePort.B + ); + } else { + throw new Error('构建link关联关系错误!'); + } + } + }); + } + // cacheTurnoutPort(map: Map, device) { + // const pList = map.get(deviceId); + // if (pList) { + // pList.push(device.devicePort); + // generated.set(g.id, pList); + // } else { + // generated.set(g.id, [device.devicePort]); + // } + // } + /** + * 一键生成link + */ oneGenerates() { const axleCountingList = this.app.queryStore.queryByType( AxleCounting.Type ); const turnoutList = this.app.queryStore.queryByType(Turnout.Type); const generated = new Map(); + const axleRefLink: Map = new Map(); axleCountingList.forEach((axleCounting) => { axleCounting.datas.axleCountingRef.forEach((device) => { const g = this.app.queryStore.queryById(device.id); if (g.type === Section.Type && !generated.get(device.id)) { - const g1 = axleCountingList.find((axleCounting) => { - const s = axleCounting.datas.axleCountingRef.find( - (ref) => ref.id === device.id + const axle1 = axleCountingList.find((axleCountingNew) => { + const s = axleCountingNew.datas.axleCountingRef.find( + (ref) => + ref.id === device.id && axleCountingNew.id !== axleCounting.id ); return s; }); - if (g1) { - this.generateBySection(g as Section); + if (axle1) { + const link = this.generateBySection( + g as Section, + device, + axleCounting, + axle1 + ); generated.set(g.id, ['A', 'B']); + this.cacheAxleLinkRelation(axleRefLink, axleCounting.id, link.id); + this.cacheAxleLinkRelation(axleRefLink, axle1.id, link.id); } } else if (g.type === Turnout.Type) { - this.generateByTurnoutAxle(g as Turnout, device.devicePort); + const link = this.generateByTurnoutAxle( + g as Turnout, + device.devicePort, + axleCounting + ); + this.cacheAxleLinkRelation(axleRefLink, axleCounting.id, link.id); if (generated.get(g.id)) { const pList = generated.get(g.id); pList.push(device.devicePort); @@ -210,7 +430,9 @@ export class SectionLinkDraw extends GraphicDrawAssistant< } } }); + this.buildLinkRef(axleRefLink); } + clearCache(): void { this.points = []; this.graphic.clear(); 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 a73b14d..31e8f66 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(); } @@ -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(); } } @@ -2905,7 +2928,8 @@ export namespace graphicData { paRef?: RelatedRef; pbRef?: RelatedRef; sectionType?: Section.SectionType; - children?: string[]; + axleCountings?: string[]; + index?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 7], this.#one_of_decls); @@ -2928,8 +2952,11 @@ export namespace graphicData { if ("sectionType" in data && data.sectionType != undefined) { this.sectionType = data.sectionType; } - if ("children" in data && data.children != undefined) { - this.children = data.children; + if ("axleCountings" in data && data.axleCountings != undefined) { + this.axleCountings = data.axleCountings; + } + if ("index" in data && data.index != undefined) { + this.index = data.index; } } } @@ -2978,12 +3005,18 @@ export namespace graphicData { set sectionType(value: Section.SectionType) { pb_1.Message.setField(this, 6, value); } - get children() { + get axleCountings() { return pb_1.Message.getFieldWithDefault(this, 7, []) as string[]; } - set children(value: string[]) { + set axleCountings(value: string[]) { pb_1.Message.setField(this, 7, value); } + get index() { + return pb_1.Message.getFieldWithDefault(this, 8, 0) as number; + } + set index(value: number) { + pb_1.Message.setField(this, 8, value); + } static fromObject(data: { common?: ReturnType; code?: string; @@ -2991,7 +3024,8 @@ export namespace graphicData { paRef?: ReturnType; pbRef?: ReturnType; sectionType?: Section.SectionType; - children?: string[]; + axleCountings?: string[]; + index?: number; }): Section { const message = new Section({}); if (data.common != null) { @@ -3012,8 +3046,11 @@ export namespace graphicData { if (data.sectionType != null) { message.sectionType = data.sectionType; } - if (data.children != null) { - message.children = data.children; + if (data.axleCountings != null) { + message.axleCountings = data.axleCountings; + } + if (data.index != null) { + message.index = data.index; } return message; } @@ -3025,7 +3062,8 @@ export namespace graphicData { paRef?: ReturnType; pbRef?: ReturnType; sectionType?: Section.SectionType; - children?: string[]; + axleCountings?: string[]; + index?: number; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -3045,8 +3083,11 @@ export namespace graphicData { if (this.sectionType != null) { data.sectionType = this.sectionType; } - if (this.children != null) { - data.children = this.children; + if (this.axleCountings != null) { + data.axleCountings = this.axleCountings; + } + if (this.index != null) { + data.index = this.index; } return data; } @@ -3066,8 +3107,10 @@ export namespace graphicData { writer.writeMessage(5, this.pbRef, () => this.pbRef.serialize(writer)); if (this.sectionType != Section.SectionType.Physical) writer.writeEnum(6, this.sectionType); - if (this.children.length) - writer.writeRepeatedString(7, this.children); + if (this.axleCountings.length) + writer.writeRepeatedString(7, this.axleCountings); + if (this.index != 0) + writer.writeInt32(8, this.index); if (!w) return writer.getResultBuffer(); } @@ -3098,6 +3141,9 @@ export namespace graphicData { case 7: pb_1.Message.addToRepeatedField(message, 7, reader.readString()); break; + case 8: + message.index = reader.readInt32(); + break; default: reader.skipField(); } } @@ -3113,7 +3159,6 @@ export namespace graphicData { export namespace Section { export enum SectionType { Physical = 0, - Logic = 1, TurnoutPhysical = 2 } } @@ -3351,7 +3396,8 @@ export namespace graphicData { Section = 0, Turnout = 1, TrainWindow = 2, - AxleCounting = 3 + AxleCounting = 3, + SectionLink = 4 } export enum DevicePort { A = 0, @@ -3359,6 +3405,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[] | { @@ -3475,13 +3611,113 @@ export namespace graphicData { return Separator.deserialize(bytes); } } + export class SimpleRef extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + deviceType?: SimpleRef.DeviceType; + id?: 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 ("deviceType" in data && data.deviceType != undefined) { + this.deviceType = data.deviceType; + } + if ("id" in data && data.id != undefined) { + this.id = data.id; + } + } + } + get deviceType() { + return pb_1.Message.getFieldWithDefault(this, 1, SimpleRef.DeviceType.Turnout) as SimpleRef.DeviceType; + } + set deviceType(value: SimpleRef.DeviceType) { + pb_1.Message.setField(this, 1, value); + } + get id() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set id(value: string) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + deviceType?: SimpleRef.DeviceType; + id?: string; + }): SimpleRef { + const message = new SimpleRef({}); + if (data.deviceType != null) { + message.deviceType = data.deviceType; + } + if (data.id != null) { + message.id = data.id; + } + return message; + } + toObject() { + const data: { + deviceType?: SimpleRef.DeviceType; + id?: string; + } = {}; + if (this.deviceType != null) { + data.deviceType = this.deviceType; + } + if (this.id != null) { + data.id = this.id; + } + 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.deviceType != SimpleRef.DeviceType.Turnout) + writer.writeEnum(1, this.deviceType); + if (this.id.length) + writer.writeString(2, this.id); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SimpleRef { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SimpleRef(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.deviceType = reader.readEnum(); + break; + case 2: + message.id = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): SimpleRef { + return SimpleRef.deserialize(bytes); + } + } + export namespace SimpleRef { + export enum DeviceType { + Turnout = 0, + AxleCounting = 1 + } + } export class SectionLink extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { common?: CommonInfo; code?: string; points?: Point[]; - refDevice?: string; + up?: boolean; + aSimRef?: SimpleRef; + bSimRef?: SimpleRef; + aRef?: RelatedRef; + bRef?: RelatedRef; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls); @@ -3495,8 +3731,20 @@ export namespace graphicData { if ("points" in data && data.points != undefined) { this.points = data.points; } - if ("refDevice" in data && data.refDevice != undefined) { - this.refDevice = data.refDevice; + if ("up" in data && data.up != undefined) { + this.up = data.up; + } + if ("aSimRef" in data && data.aSimRef != undefined) { + this.aSimRef = data.aSimRef; + } + if ("bSimRef" in data && data.bSimRef != undefined) { + this.bSimRef = data.bSimRef; + } + if ("aRef" in data && data.aRef != undefined) { + this.aRef = data.aRef; + } + if ("bRef" in data && data.bRef != undefined) { + this.bRef = data.bRef; } } } @@ -3521,17 +3769,57 @@ export namespace graphicData { set points(value: Point[]) { pb_1.Message.setRepeatedWrapperField(this, 3, value); } - get refDevice() { - return pb_1.Message.getFieldWithDefault(this, 4, "") as string; + get up() { + return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean; } - set refDevice(value: string) { + set up(value: boolean) { pb_1.Message.setField(this, 4, value); } + get aSimRef() { + return pb_1.Message.getWrapperField(this, SimpleRef, 5) as SimpleRef; + } + set aSimRef(value: SimpleRef) { + pb_1.Message.setWrapperField(this, 5, value); + } + get has_aSimRef() { + return pb_1.Message.getField(this, 5) != null; + } + get bSimRef() { + return pb_1.Message.getWrapperField(this, SimpleRef, 6) as SimpleRef; + } + set bSimRef(value: SimpleRef) { + pb_1.Message.setWrapperField(this, 6, value); + } + get has_bSimRef() { + return pb_1.Message.getField(this, 6) != null; + } + get aRef() { + return pb_1.Message.getWrapperField(this, RelatedRef, 7) as RelatedRef; + } + set aRef(value: RelatedRef) { + pb_1.Message.setWrapperField(this, 7, value); + } + get has_aRef() { + return pb_1.Message.getField(this, 7) != null; + } + get bRef() { + return pb_1.Message.getWrapperField(this, RelatedRef, 8) as RelatedRef; + } + set bRef(value: RelatedRef) { + pb_1.Message.setWrapperField(this, 8, value); + } + get has_bRef() { + return pb_1.Message.getField(this, 8) != null; + } static fromObject(data: { common?: ReturnType; code?: string; points?: ReturnType[]; - refDevice?: string; + up?: boolean; + aSimRef?: ReturnType; + bSimRef?: ReturnType; + aRef?: ReturnType; + bRef?: ReturnType; }): SectionLink { const message = new SectionLink({}); if (data.common != null) { @@ -3543,8 +3831,20 @@ export namespace graphicData { if (data.points != null) { message.points = data.points.map(item => Point.fromObject(item)); } - if (data.refDevice != null) { - message.refDevice = data.refDevice; + if (data.up != null) { + message.up = data.up; + } + if (data.aSimRef != null) { + message.aSimRef = SimpleRef.fromObject(data.aSimRef); + } + if (data.bSimRef != null) { + message.bSimRef = SimpleRef.fromObject(data.bSimRef); + } + if (data.aRef != null) { + message.aRef = RelatedRef.fromObject(data.aRef); + } + if (data.bRef != null) { + message.bRef = RelatedRef.fromObject(data.bRef); } return message; } @@ -3553,7 +3853,11 @@ export namespace graphicData { common?: ReturnType; code?: string; points?: ReturnType[]; - refDevice?: string; + up?: boolean; + aSimRef?: ReturnType; + bSimRef?: ReturnType; + aRef?: ReturnType; + bRef?: ReturnType; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -3564,8 +3868,20 @@ export namespace graphicData { if (this.points != null) { data.points = this.points.map((item: Point) => item.toObject()); } - if (this.refDevice != null) { - data.refDevice = this.refDevice; + if (this.up != null) { + data.up = this.up; + } + if (this.aSimRef != null) { + data.aSimRef = this.aSimRef.toObject(); + } + if (this.bSimRef != null) { + data.bSimRef = this.bSimRef.toObject(); + } + if (this.aRef != null) { + data.aRef = this.aRef.toObject(); + } + if (this.bRef != null) { + data.bRef = this.bRef.toObject(); } return data; } @@ -3579,8 +3895,16 @@ export namespace graphicData { writer.writeString(2, this.code); if (this.points.length) writer.writeRepeatedMessage(3, this.points, (item: Point) => item.serialize(writer)); - if (this.refDevice.length) - writer.writeString(4, this.refDevice); + if (this.up != false) + writer.writeBool(4, this.up); + if (this.has_aSimRef) + writer.writeMessage(5, this.aSimRef, () => this.aSimRef.serialize(writer)); + if (this.has_bSimRef) + writer.writeMessage(6, this.bSimRef, () => this.bSimRef.serialize(writer)); + if (this.has_aRef) + writer.writeMessage(7, this.aRef, () => this.aRef.serialize(writer)); + if (this.has_bRef) + writer.writeMessage(8, this.bRef, () => this.bRef.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -3600,7 +3924,19 @@ export namespace graphicData { reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Point.deserialize(reader), Point)); break; case 4: - message.refDevice = reader.readString(); + message.up = reader.readBool(); + break; + case 5: + reader.readMessage(message.aSimRef, () => message.aSimRef = SimpleRef.deserialize(reader)); + break; + case 6: + reader.readMessage(message.bSimRef, () => message.bSimRef = SimpleRef.deserialize(reader)); + break; + case 7: + reader.readMessage(message.aRef, () => message.aRef = RelatedRef.deserialize(reader)); + break; + case 8: + reader.readMessage(message.bRef, () => message.bRef = RelatedRef.deserialize(reader)); break; default: reader.skipField(); } @@ -3622,9 +3958,11 @@ export namespace graphicData { points?: Point[]; paRef?: RelatedRef; pbRef?: RelatedRef; + turnoutPos?: TurnoutPosRef[]; + indexNumber?: number; }) { 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 +3979,12 @@ 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; + } + if ("indexNumber" in data && data.indexNumber != undefined) { + this.indexNumber = data.indexNumber; + } } } get common() { @@ -3682,12 +4026,26 @@ 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); + } + 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; points?: ReturnType[]; paRef?: ReturnType; pbRef?: ReturnType; + turnoutPos?: ReturnType[]; + indexNumber?: number; }): AxleCountingSection { const message = new AxleCountingSection({}); if (data.common != null) { @@ -3705,6 +4063,12 @@ 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)); + } + if (data.indexNumber != null) { + message.indexNumber = data.indexNumber; + } return message; } toObject() { @@ -3714,6 +4078,8 @@ export namespace graphicData { points?: ReturnType[]; paRef?: ReturnType; pbRef?: ReturnType; + turnoutPos?: ReturnType[]; + indexNumber?: number; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -3730,6 +4096,12 @@ 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()); + } + if (this.indexNumber != null) { + data.indexNumber = this.indexNumber; + } return data; } serialize(): Uint8Array; @@ -3746,6 +4118,10 @@ 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 (this.indexNumber != 0) + writer.writeInt32(7, this.indexNumber); if (!w) return writer.getResultBuffer(); } @@ -3770,6 +4146,12 @@ 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; + case 7: + message.indexNumber = reader.readInt32(); + break; default: reader.skipField(); } } @@ -3782,4 +4164,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 691c82bd50e5fd65d700b8ab178b1431c98ffb72 Mon Sep 17 00:00:00 2001 From: fan Date: Wed, 12 Jul 2023 13:06:16 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graphic-pixi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphic-pixi b/graphic-pixi index f89c8eb..0a0cb0a 160000 --- a/graphic-pixi +++ b/graphic-pixi @@ -1 +1 @@ -Subproject commit f89c8eb48de7b2e39a93c4aab9b4e5ff1a9e91b4 +Subproject commit 0a0cb0a77afd9783081c2dc6ba19687b0b3aa0f7 From 1a74406d05838cc641dc018ddae1989a3aa25ef5 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 12 Jul 2023 13:10:17 +0800 Subject: [PATCH 3/9] =?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/JlGraphicApp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jl-graphic/app/JlGraphicApp.ts b/src/jl-graphic/app/JlGraphicApp.ts index 4be56ea..5cf08f3 100644 --- a/src/jl-graphic/app/JlGraphicApp.ts +++ b/src/jl-graphic/app/JlGraphicApp.ts @@ -737,7 +737,7 @@ export class GraphicApp extends EventEmitter { deleteGraphics(...graphics: JlGraphic[]): JlGraphic[] { const dels = graphics.filter((g) => { if ( - this._options?.isSupportDeletion && + this._options?.isSupportDeletion == undefined || this._options.isSupportDeletion(g) ) { this.doDeleteGraphics(g); From 28dc36b679ad1e8de6b5f1f232add669d9b204fc Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 12 Jul 2023 13:20:16 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=BD=93=E5=89=8D=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drawApp/index.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 13db706..a00aff1 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -9,6 +9,7 @@ import { GraphicApp, GraphicData, JlDrawApp, + JlGraphic, KeyListener, } from 'src/jl-graphic'; import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; @@ -77,6 +78,7 @@ import { LogicSectionTemplate, } from 'src/graphics/logicSection/LogicSection'; import { LogicSectionData } from './graphics/LogicSectionInteraction'; +import { Notify } from 'quasar'; // export function fromStoragePoint(p: graphicData.Point): Point { // return new Point(p.x, p.y); @@ -233,8 +235,18 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { ]; DrawSignalInteraction.init(app); } - - app.setOptions({ drawAssistants: drawAssistants }); + const isSupportDeletion = (g: JlGraphic) => { + if (g.type === LogicSection.Type && g.selected) { + Notify.create({ + type: 'warning', + message: '逻辑区段不支持删除', + timeout: 1000, + }); + return false; + } + return true; + }; + app.setOptions({ drawAssistants: drawAssistants, isSupportDeletion }); // 画布右键菜单 app.registerMenu(DefaultCanvasMenu); From 980e5dfbd273908daa55ce13b980691b40cc1bc5 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Wed, 12 Jul 2023 13:54:38 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E7=94=9F=E6=88=90?= =?UTF-8?q?=E4=BF=AE=E6=94=B9--=E4=B8=8D=E6=8B=86=E7=89=A9=E7=90=86?= =?UTF-8?q?=E5=8C=BA=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/axleCounting/AxleCountingDrawAssistant.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts index 7ac26b5..9c96200 100644 --- a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts +++ b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts @@ -191,12 +191,6 @@ export class AxleCountingDraw extends GraphicDrawAssistant< if (axleCountingPs.y > height.y) { direction = -1; } - if ( - section.datas.sectionType === SectionType.Logic || - section.datas.children.includes(refDevice.id) - ) { - return; - } if (refDevice.type == Section.Type || refDevice.type == Turnout.Type) this.draw( axleCountingPs, From 17343541bc7d85c9ccf72d940666d07f4affd23f Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 12 Jul 2023 13:57:13 +0800 Subject: [PATCH 6/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 --- src/graphics/separator/SeparatorDrawAssistant.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/graphics/separator/SeparatorDrawAssistant.ts b/src/graphics/separator/SeparatorDrawAssistant.ts index d1a1453..54482cd 100644 --- a/src/graphics/separator/SeparatorDrawAssistant.ts +++ b/src/graphics/separator/SeparatorDrawAssistant.ts @@ -74,10 +74,7 @@ export class SeparatorDraw extends GraphicDrawAssistant< allR.forEach((relation, index) => { const r = relation.getRelationParam(section); const other = relation.getOtherRelationParam(section); - if (!section.datas.children.includes(other.g.id)) { - // 排除物理区段和自身逻辑区段的关联关系 - port.push(r.param); - } + port.push(r.param); if (!rMap.has(setKey(r))) { rMap.set(setKey(r), { ...r }); } From cd95df7eea05282556e35326dc495e86bbfc4746 Mon Sep 17 00:00:00 2001 From: fan Date: Wed, 12 Jul 2023 13:59:16 +0800 Subject: [PATCH 7/9] =?UTF-8?q?sectionlink=E4=BB=A3=E7=A0=81=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sectionLink/SectionLinkDrawAssistant.ts | 105 +++++++++--------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts index b5f67aa..a560e6c 100644 --- a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts +++ b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts @@ -27,6 +27,9 @@ import { AxleCounting } from '../axleCounting/AxleCounting'; import { IRelatedRefData } from '../CommonGraphics'; import { graphicData } from 'src/protos/stationLayoutGraphics'; +const rrDevicePort = graphicData.RelatedRef.DevicePort; +const rrDeviceType = graphicData.RelatedRef.DeviceType; +const srDeviceType = graphicData.SimpleRef.DeviceType; export class SectionLinkDraw extends GraphicDrawAssistant< SectionLinkTemplate, ISectionLinkData @@ -131,15 +134,15 @@ export class SectionLinkDraw extends GraphicDrawAssistant< axle.id, graphicData.SimpleRef.DeviceType.AxleCounting ); - if (port === 0) { + if (port === rrDevicePort.A) { turnout.datas.pointA.forEach((p) => { points.push(turnout.localToCanvasPoint(p)); }); - } else if (port === 1) { + } else if (port === rrDevicePort.B) { turnout.datas.pointB.forEach((p) => { points.push(turnout.localToCanvasPoint(p)); }); - } else if (port === 2) { + } else if (port === rrDevicePort.C) { turnout.datas.pointC.forEach((p) => { points.push(turnout.localToCanvasPoint(p)); }); @@ -173,22 +176,16 @@ export class SectionLinkDraw extends GraphicDrawAssistant< const points: IPointData[] = [forkP1]; const refTurnout1 = this.buildRelatedRef( turnout.id, - graphicData.RelatedRef.DeviceType.Turnout, + rrDeviceType.Turnout, port ); const refTurnout2 = this.buildRelatedRef( pRef.id, - graphicData.RelatedRef.DeviceType.Turnout, + rrDeviceType.Turnout, pRef.devicePort ); - const refSimT1 = this.buildSimpleRef( - turnout.id, - graphicData.SimpleRef.DeviceType.Turnout - ); - const refSimT2 = this.buildSimpleRef( - pRef.id, - graphicData.SimpleRef.DeviceType.Turnout - ); + const refSimT1 = this.buildSimpleRef(turnout.id, srDeviceType.Turnout); + const refSimT2 = this.buildSimpleRef(pRef.id, srDeviceType.Turnout); if (forkP1.x > forkP2.x) { sectionLink.datas.aSimRef = refSimT2; sectionLink.datas.bSimRef = refSimT1; @@ -216,11 +213,11 @@ export class SectionLinkDraw extends GraphicDrawAssistant< }); } let dataPoint: IPointData[] = []; - if (port === 0) { + if (port === rrDevicePort.A) { dataPoint = turnout.datas.pointA; - } else if (port === 1) { + } else if (port === rrDevicePort.B) { dataPoint = turnout.datas.pointB; - } else if (port === 2) { + } else if (port === rrDevicePort.C) { dataPoint = turnout.datas.pointC; } const pLength = dataPoint.length; @@ -331,15 +328,25 @@ export class SectionLinkDraw extends GraphicDrawAssistant< } }); } - // cacheTurnoutPort(map: Map, device) { - // const pList = map.get(deviceId); - // if (pList) { - // pList.push(device.devicePort); - // generated.set(g.id, pList); - // } else { - // generated.set(g.id, [device.devicePort]); - // } - // } + /** + * 存储生成link的道岔端口 + * @param map + * @param deviceId + * @param devicePort + */ + cacheTurnoutPort( + map: Map, + deviceId: string, + devicePort: graphicData.RelatedRef.DevicePort + ) { + const pList = map.get(deviceId); + if (pList) { + pList.push(devicePort); + map.set(deviceId, pList); + } else { + map.set(deviceId, [devicePort]); + } + } /** * 一键生成link */ @@ -348,12 +355,16 @@ export class SectionLinkDraw extends GraphicDrawAssistant< AxleCounting.Type ); const turnoutList = this.app.queryStore.queryByType(Turnout.Type); - const generated = new Map(); + // 已生成link和计轴的关联关系数据 const axleRefLink: Map = new Map(); + // 已生成link的道岔各个端口缓存数据 + const tpMap: Map = new Map(); + // 已生成link的section数据(两计轴之间的区段) + const gSectionList: string[] = []; axleCountingList.forEach((axleCounting) => { axleCounting.datas.axleCountingRef.forEach((device) => { const g = this.app.queryStore.queryById(device.id); - if (g.type === Section.Type && !generated.get(device.id)) { + if (g.type === Section.Type && !gSectionList.includes(device.id)) { const axle1 = axleCountingList.find((axleCountingNew) => { const s = axleCountingNew.datas.axleCountingRef.find( (ref) => @@ -368,7 +379,7 @@ export class SectionLinkDraw extends GraphicDrawAssistant< axleCounting, axle1 ); - generated.set(g.id, ['A', 'B']); + gSectionList.push(g.id); this.cacheAxleLinkRelation(axleRefLink, axleCounting.id, link.id); this.cacheAxleLinkRelation(axleRefLink, axle1.id, link.id); } @@ -379,55 +390,43 @@ export class SectionLinkDraw extends GraphicDrawAssistant< axleCounting ); this.cacheAxleLinkRelation(axleRefLink, axleCounting.id, link.id); - if (generated.get(g.id)) { - const pList = generated.get(g.id); - pList.push(device.devicePort); - generated.set(g.id, pList); - } else { - generated.set(g.id, [device.devicePort]); - } + this.cacheTurnoutPort(tpMap, g.id, device.devicePort); } }); }); turnoutList.forEach((turnout) => { - const pList = generated.get(turnout.id); + const pList = tpMap.get(turnout.id); if (!pList) { return; } let pRef = null; if ( - !pList.includes(0) && + !pList.includes(rrDevicePort.A) && turnout.datas.paRef && - turnout.datas.paRef.deviceType === 1 + turnout.datas.paRef.deviceType === rrDeviceType.Turnout ) { pRef = turnout.datas.paRef; - this.generateByTurnout(turnout, 0, pRef); + this.generateByTurnout(turnout, rrDevicePort.A, pRef); } if ( - !pList.includes(1) && + !pList.includes(rrDevicePort.B) && turnout.datas.pbRef && - turnout.datas.pbRef.deviceType === 1 + turnout.datas.pbRef.deviceType === rrDeviceType.Turnout ) { pRef = turnout.datas.pbRef; - this.generateByTurnout(turnout, 1, pRef); + this.generateByTurnout(turnout, rrDevicePort.B, pRef); } if ( - !pList.includes(2) && + !pList.includes(rrDevicePort.C) && turnout.datas.pcRef && - turnout.datas.pcRef.deviceType === 1 + turnout.datas.pcRef.deviceType === rrDeviceType.Turnout ) { pRef = turnout.datas.pcRef; - this.generateByTurnout(turnout, 2, pRef); + this.generateByTurnout(turnout, rrDevicePort.C, pRef); } - generated.set(turnout.id, [0, 1, 2]); + tpMap.set(turnout.id, [rrDevicePort.A, rrDevicePort.B, rrDevicePort.C]); if (pRef) { - if (generated.get(pRef.id)) { - const pListn = generated.get(pRef.id); - pListn.push(pRef.devicePort); - generated.set(pRef.id, pListn); - } else { - generated.set(pRef.id, [pRef.devicePort]); - } + this.cacheTurnoutPort(tpMap, pRef.id, pRef.devicePort); } }); this.buildLinkRef(axleRefLink); From 072b44be905150630fe03e8acdeb2c159ccf4ee4 Mon Sep 17 00:00:00 2001 From: fan Date: Wed, 12 Jul 2023 14:03:35 +0800 Subject: [PATCH 8/9] =?UTF-8?q?sectionLink=E4=BB=A3=E7=A0=81=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sectionLink/SectionLinkDrawAssistant.ts | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts index a560e6c..b21e671 100644 --- a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts +++ b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts @@ -83,9 +83,8 @@ export class SectionLinkDraw extends GraphicDrawAssistant< points.push(section.localToCanvasPoint(p)); }); sectionLink.datas.points = points; - const DeviceType = graphicData.SimpleRef.DeviceType; - const refAxle1 = this.buildSimpleRef(axle1.id, DeviceType.AxleCounting); - const refAxle2 = this.buildSimpleRef(axle2.id, DeviceType.AxleCounting); + const refAxle1 = this.buildSimpleRef(axle1.id, srDeviceType.AxleCounting); + const refAxle2 = this.buildSimpleRef(axle2.id, srDeviceType.AxleCounting); /** * 判断link AB端 A端一定在左侧(根据计轴关联区段判断区段AB端是否倒序) */ @@ -123,17 +122,11 @@ export class SectionLinkDraw extends GraphicDrawAssistant< const points: IPointData[] = [forkP]; const refTurnout = this.buildRelatedRef( turnout.id, - graphicData.RelatedRef.DeviceType.Turnout, + rrDeviceType.Turnout, port ); - const refSimTurnout = this.buildSimpleRef( - turnout.id, - graphicData.SimpleRef.DeviceType.Turnout - ); - const refAxle = this.buildSimpleRef( - axle.id, - graphicData.SimpleRef.DeviceType.AxleCounting - ); + const refSimTurnout = this.buildSimpleRef(turnout.id, srDeviceType.Turnout); + const refAxle = this.buildSimpleRef(axle.id, srDeviceType.AxleCounting); if (port === rrDevicePort.A) { turnout.datas.pointA.forEach((p) => { points.push(turnout.localToCanvasPoint(p)); @@ -272,8 +265,6 @@ export class SectionLinkDraw extends GraphicDrawAssistant< } /**构建link之间的关联关系 */ buildLinkRef(map: Map) { - const DeviceType = graphicData.RelatedRef.DeviceType; - const DevicePort = graphicData.RelatedRef.DevicePort; map.forEach((value) => { if (value.length === 2) { const link1 = this.app.queryStore.queryById(value[0]) as SectionLink; @@ -281,46 +272,46 @@ export class SectionLinkDraw extends GraphicDrawAssistant< if (link1.datas.aSimRef.id === link2.datas.bSimRef.id) { link1.datas.aRef = this.buildRelatedRef( link2.id, - DeviceType.SectionLink, - DevicePort.B + rrDeviceType.SectionLink, + rrDevicePort.B ); link2.datas.bRef = this.buildRelatedRef( link1.id, - DeviceType.SectionLink, - DevicePort.A + rrDeviceType.SectionLink, + rrDevicePort.A ); } else if (link1.datas.bSimRef.id === link2.datas.aSimRef.id) { link1.datas.bRef = this.buildRelatedRef( link2.id, - DeviceType.SectionLink, - DevicePort.A + rrDeviceType.SectionLink, + rrDevicePort.A ); link2.datas.aRef = this.buildRelatedRef( link1.id, - DeviceType.SectionLink, - DevicePort.B + rrDeviceType.SectionLink, + rrDevicePort.B ); } else if (link1.datas.aSimRef.id === link2.datas.aSimRef.id) { link1.datas.aRef = this.buildRelatedRef( link2.id, - DeviceType.SectionLink, - DevicePort.A + rrDeviceType.SectionLink, + rrDevicePort.A ); link2.datas.aRef = this.buildRelatedRef( link1.id, - DeviceType.SectionLink, - DevicePort.A + rrDeviceType.SectionLink, + rrDevicePort.A ); } else if (link1.datas.bSimRef.id === link2.datas.bSimRef.id) { link1.datas.bRef = this.buildRelatedRef( link2.id, - DeviceType.SectionLink, - DevicePort.B + rrDeviceType.SectionLink, + rrDevicePort.B ); link2.datas.bRef = this.buildRelatedRef( link1.id, - DeviceType.SectionLink, - DevicePort.B + rrDeviceType.SectionLink, + rrDevicePort.B ); } else { throw new Error('构建link关联关系错误!'); From 831960b031f9c1fa8d3aaf38466a9176af2ad9d7 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Wed, 12 Jul 2023 14:04:45 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/axleCounting/AxleCountingDrawAssistant.ts | 2 +- .../axleCountingSection/AxleCountingSectionAssistant.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts index 9c96200..0935ef6 100644 --- a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts +++ b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts @@ -15,7 +15,7 @@ import { AxleCounting, AxleCountingTemplate, } from './AxleCounting'; -import { Section, SectionPort, SectionType } from '../section/Section'; +import { Section, SectionPort } from '../section/Section'; import { Turnout, TurnoutPort } from '../turnout/Turnout'; import { IRelatedRefData, createRelatedRefProto } from '../CommonGraphics'; import { Signal } from '../signal/Signal'; diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index 6d9e64e..0c54379 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -394,7 +394,6 @@ export class AxleCountingSectionInteraction extends GraphicInteractionPlugin @@ -407,9 +406,8 @@ export class AxleCountingSectionInteraction extends GraphicInteractionPlugin { + points.forEach((ps) => { const data = new LogicSectionData(); data.id = GraphicIdGenerator.next(); data.axleSectionId = axleCountingSection.id;