link 关联设备调整

This commit is contained in:
fan 2023-08-09 11:16:13 +08:00
parent b3c7646fba
commit 4ef7437a5a

View File

@ -10,8 +10,9 @@ import {
} from 'src/jl-graphic'; } from 'src/jl-graphic';
import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin'; import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin';
import { graphicData } from 'src/protos/stationLayoutGraphics'; import { graphicData } from 'src/protos/stationLayoutGraphics';
import { AxleCounting } from '../axleCounting/AxleCounting';
import { IRelatedRefData, DevicePosition } from '../CommonGraphics'; import { IRelatedRefData, DevicePosition } from '../CommonGraphics';
import { Section } from '../section/Section'; import { Section, SectionPort } from '../section/Section';
import { Turnout } from '../turnout/Turnout'; import { Turnout } from '../turnout/Turnout';
export interface ILinkData extends GraphicData { export interface ILinkData extends GraphicData {
@ -95,11 +96,14 @@ export class Link extends JlGraphic implements ILineGraphic {
getDevicePoint(id: string, devicePort: number) { getDevicePoint(id: string, devicePort: number) {
const device = this.queryStore.queryById(id); const device = this.queryStore.queryById(id);
if (device.type === Section.Type) { if (device.type === AxleCounting.Type) {
if (devicePort === graphicData.RelatedRef.DevicePort.A) { const relations = device.queryRelationByType(Section.Type);
return device.localToCanvasPoint((device as Section).getStartPoint()); const relation = relations[0].getOtherRelationParam(device);
} else if (devicePort === graphicData.RelatedRef.DevicePort.B) { const section = relations[0].getOtherGraphic<Section>(device);
return device.localToCanvasPoint((device as Section).getEndPoint()); if (relation.param === SectionPort.A) {
return section.localToCanvasPoint(section.getStartPoint());
} else if (relation.param === SectionPort.B) {
return section.localToCanvasPoint(section.getEndPoint());
} else { } else {
console.error(devicePort, device); console.error(devicePort, device);
throw new Error('Link关联设备端口错误!'); throw new Error('Link关联设备端口错误!');