一键生成信号机停车标的设备关联关系
This commit is contained in:
parent
ed4a2d2751
commit
2bb166abbe
@ -1 +1 @@
|
|||||||
Subproject commit 86bf1f0c76ade5866afd8063e8f263ca9eda55a5
|
Subproject commit 1db196077c6293a757d3462b0aa0c7a62d219035
|
@ -37,6 +37,7 @@
|
|||||||
style="margin-top: 10px"
|
style="margin-top: 10px"
|
||||||
v-model="refDevData.deviceType"
|
v-model="refDevData.deviceType"
|
||||||
:options="DeviceTypeOptions"
|
:options="DeviceTypeOptions"
|
||||||
|
:readonly="true"
|
||||||
:map-options="true"
|
:map-options="true"
|
||||||
:emit-value="true"
|
:emit-value="true"
|
||||||
@update:model-value="onUpdate"
|
@update:model-value="onUpdate"
|
||||||
@ -47,6 +48,7 @@
|
|||||||
v-if="refDevData.deviceType === graphicData.RelatedRef.DeviceType.Section"
|
v-if="refDevData.deviceType === graphicData.RelatedRef.DeviceType.Section"
|
||||||
style="margin-top: 10px"
|
style="margin-top: 10px"
|
||||||
v-model="refDevData.id"
|
v-model="refDevData.id"
|
||||||
|
:readonly="true"
|
||||||
:options="sectionList"
|
:options="sectionList"
|
||||||
:map-options="true"
|
:map-options="true"
|
||||||
:emit-value="true"
|
:emit-value="true"
|
||||||
@ -59,6 +61,7 @@
|
|||||||
style="margin-top: 10px"
|
style="margin-top: 10px"
|
||||||
v-model="refDevData.id"
|
v-model="refDevData.id"
|
||||||
:options="turnoutList"
|
:options="turnoutList"
|
||||||
|
:readonly="true"
|
||||||
:map-options="true"
|
:map-options="true"
|
||||||
:emit-value="true"
|
:emit-value="true"
|
||||||
@update:model-value="onUpdate"
|
@update:model-value="onUpdate"
|
||||||
@ -70,6 +73,7 @@
|
|||||||
style="margin-top: 10px"
|
style="margin-top: 10px"
|
||||||
v-model="refDevData.devicePort"
|
v-model="refDevData.devicePort"
|
||||||
:options="DevicePortOptions"
|
:options="DevicePortOptions"
|
||||||
|
:readonly="true"
|
||||||
:map-options="true"
|
:map-options="true"
|
||||||
:emit-value="true"
|
:emit-value="true"
|
||||||
@update:model-value="onUpdate"
|
@update:model-value="onUpdate"
|
||||||
@ -123,6 +127,10 @@ function initRefData(signal: Signal) {
|
|||||||
refDevData.id = signalModel.refDev.id;
|
refDevData.id = signalModel.refDev.id;
|
||||||
refDevData.devicePort = signalModel.refDev.devicePort;
|
refDevData.devicePort = signalModel.refDev.devicePort;
|
||||||
refDevData.deviceType = signalModel.refDev.deviceType;
|
refDevData.deviceType = signalModel.refDev.deviceType;
|
||||||
|
} else {
|
||||||
|
refDevData.id = '';
|
||||||
|
refDevData.deviceType = graphicData.RelatedRef.DeviceType.Section;
|
||||||
|
refDevData.devicePort = graphicData.RelatedRef.DevicePort.A;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function initDeviceList() {
|
function initDeviceList() {
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
v-model="refDevData.id"
|
v-model="refDevData.id"
|
||||||
:options="sectionList"
|
:options="sectionList"
|
||||||
:map-options="true"
|
:map-options="true"
|
||||||
|
:readonly="true"
|
||||||
:emit-value="true"
|
:emit-value="true"
|
||||||
@update:model-value="onUpdate"
|
@update:model-value="onUpdate"
|
||||||
label="关联设备"
|
label="关联设备"
|
||||||
@ -120,6 +121,8 @@ function initRefData(stopPosition: StopPosition) {
|
|||||||
}
|
}
|
||||||
if (stopPositionModel.refDev) {
|
if (stopPositionModel.refDev) {
|
||||||
refDevData.id = stopPositionModel.refDev.id;
|
refDevData.id = stopPositionModel.refDev.id;
|
||||||
|
} else {
|
||||||
|
refDevData.id = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
import { Graphics, Point } from 'pixi.js';
|
import { Graphics, Point } from 'pixi.js';
|
||||||
import {
|
import {
|
||||||
|
calculateDistanceFromPointToLine,
|
||||||
|
calculateFootPointFromPointToLine,
|
||||||
GraphicData,
|
GraphicData,
|
||||||
GraphicState,
|
GraphicState,
|
||||||
|
isPointOnLine,
|
||||||
JlGraphic,
|
JlGraphic,
|
||||||
JlGraphicTemplate,
|
JlGraphicTemplate,
|
||||||
} from 'src/jl-graphic';
|
} from 'src/jl-graphic';
|
||||||
import { calculateMirrorPoint } from 'src/jl-graphic';
|
import { calculateMirrorPoint } from 'src/jl-graphic';
|
||||||
import { LampMainBody } from './LampMainBody';
|
import { LampMainBody } from './LampMainBody';
|
||||||
import { drawArrow, IRelatedRefData } from '../CommonGraphics';
|
import {
|
||||||
|
drawArrow,
|
||||||
|
IRelatedRefData,
|
||||||
|
createRelatedRefProto,
|
||||||
|
} from '../CommonGraphics';
|
||||||
import { SignalCode } from './SignalCode';
|
import { SignalCode } from './SignalCode';
|
||||||
|
import { Section, SectionPort } from '../section/Section';
|
||||||
|
import { Turnout, TurnoutPort } from '../turnout/Turnout';
|
||||||
|
|
||||||
export interface KilometerSystem {
|
export interface KilometerSystem {
|
||||||
get coordinateSystem(): string;
|
get coordinateSystem(): string;
|
||||||
@ -197,6 +206,91 @@ export class Signal extends JlGraphic {
|
|||||||
}
|
}
|
||||||
this.humanControl.endFill();
|
this.humanControl.endFill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildRelation() {
|
||||||
|
const sections = this.queryStore.queryByType<Section>(Section.Type);
|
||||||
|
const turnouts = this.queryStore.queryByType<Turnout>(Turnout.Type);
|
||||||
|
let deviceId = '';
|
||||||
|
let deviceType = '';
|
||||||
|
let minD = Number.MAX_SAFE_INTEGER;
|
||||||
|
let port: SectionPort | TurnoutPort = SectionPort.A;
|
||||||
|
sections.forEach((sec: Section) => {
|
||||||
|
for (let i = 0; i < sec.datas.points.length - 1; i++) {
|
||||||
|
const d = calculateDistanceFromPointToLine(
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i]),
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i + 1]),
|
||||||
|
this.position
|
||||||
|
);
|
||||||
|
const p = calculateFootPointFromPointToLine(
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i]),
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i + 1]),
|
||||||
|
this.position
|
||||||
|
);
|
||||||
|
const onLine = isPointOnLine(
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i]),
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i + 1]),
|
||||||
|
p
|
||||||
|
);
|
||||||
|
if (onLine && d < minD) {
|
||||||
|
minD = d;
|
||||||
|
deviceId = sec.id;
|
||||||
|
deviceType = sec.type;
|
||||||
|
port = SectionPort.A;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
turnouts.forEach((turnout: Turnout) => {
|
||||||
|
for (let i = 0; i < turnout.datas.pointA.length; i++) {
|
||||||
|
const p1 = turnout.localToCanvasPoint(
|
||||||
|
i === 0 ? new Point(0, 0) : turnout.datas.pointA[i - 1]
|
||||||
|
);
|
||||||
|
const p2 = turnout.localToCanvasPoint(turnout.datas.pointA[i]);
|
||||||
|
const d = calculateDistanceFromPointToLine(p1, p2, this.position);
|
||||||
|
const p = calculateFootPointFromPointToLine(p1, p2, this.position);
|
||||||
|
const onLine = isPointOnLine(p1, p2, p);
|
||||||
|
if (onLine && d < minD) {
|
||||||
|
minD = d;
|
||||||
|
deviceId = turnout.id;
|
||||||
|
deviceType = turnout.type;
|
||||||
|
port = TurnoutPort.A;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let i = 0; i < turnout.datas.pointB.length; i++) {
|
||||||
|
const p1 = turnout.localToCanvasPoint(
|
||||||
|
i === 0 ? new Point(0, 0) : turnout.datas.pointB[i - 1]
|
||||||
|
);
|
||||||
|
const p2 = turnout.localToCanvasPoint(turnout.datas.pointB[i]);
|
||||||
|
const d = calculateDistanceFromPointToLine(p1, p2, this.position);
|
||||||
|
const p = calculateFootPointFromPointToLine(p1, p2, this.position);
|
||||||
|
const onLine = isPointOnLine(p1, p2, p);
|
||||||
|
if (onLine && d < minD) {
|
||||||
|
minD = d;
|
||||||
|
deviceId = turnout.id;
|
||||||
|
deviceType = turnout.type;
|
||||||
|
port = TurnoutPort.B;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let i = 0; i < turnout.datas.pointC.length; i++) {
|
||||||
|
const p1 = turnout.localToCanvasPoint(
|
||||||
|
i === 0 ? new Point(0, 0) : turnout.datas.pointC[i - 1]
|
||||||
|
);
|
||||||
|
const p2 = turnout.localToCanvasPoint(turnout.datas.pointC[i]);
|
||||||
|
const d = calculateDistanceFromPointToLine(p1, p2, this.position);
|
||||||
|
const p = calculateFootPointFromPointToLine(p1, p2, this.position);
|
||||||
|
const onLine = isPointOnLine(p1, p2, p);
|
||||||
|
if (onLine && d < minD) {
|
||||||
|
minD = d;
|
||||||
|
deviceId = turnout.id;
|
||||||
|
deviceType = turnout.type;
|
||||||
|
port = TurnoutPort.C;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (deviceId) {
|
||||||
|
this.datas.refDev = createRelatedRefProto(deviceType, deviceId, port);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SignalTemplate extends JlGraphicTemplate<Signal> {
|
export class SignalTemplate extends JlGraphicTemplate<Signal> {
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
import { Graphics } from 'pixi.js';
|
import { Graphics } from 'pixi.js';
|
||||||
import {
|
import {
|
||||||
|
calculateDistanceFromPointToLine,
|
||||||
|
calculateFootPointFromPointToLine,
|
||||||
|
isPointOnLine,
|
||||||
GraphicData,
|
GraphicData,
|
||||||
JlGraphic,
|
JlGraphic,
|
||||||
JlGraphicTemplate,
|
JlGraphicTemplate,
|
||||||
VectorText,
|
VectorText,
|
||||||
} from 'src/jl-graphic';
|
} from 'src/jl-graphic';
|
||||||
import { IRelatedRefData } from '../CommonGraphics';
|
import { IRelatedRefData, createRelatedRefProto } from '../CommonGraphics';
|
||||||
|
import { Section, SectionPort } from '../section/Section';
|
||||||
|
|
||||||
export enum CoachNum {
|
export enum CoachNum {
|
||||||
Four = 0,
|
Four = 0,
|
||||||
@ -88,6 +92,41 @@ export class StopPosition extends JlGraphic {
|
|||||||
}
|
}
|
||||||
this.signBody.endFill();
|
this.signBody.endFill();
|
||||||
}
|
}
|
||||||
|
buildRelation() {
|
||||||
|
const sections = this.queryStore.queryByType<Section>(Section.Type);
|
||||||
|
let deviceId = '';
|
||||||
|
let deviceType = '';
|
||||||
|
let minD = Number.MAX_SAFE_INTEGER;
|
||||||
|
let port = SectionPort.A;
|
||||||
|
sections.forEach((sec: Section) => {
|
||||||
|
for (let i = 0; i < sec.datas.points.length - 1; i++) {
|
||||||
|
const d = calculateDistanceFromPointToLine(
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i]),
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i + 1]),
|
||||||
|
this.position
|
||||||
|
);
|
||||||
|
const p = calculateFootPointFromPointToLine(
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i]),
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i + 1]),
|
||||||
|
this.position
|
||||||
|
);
|
||||||
|
const onLine = isPointOnLine(
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i]),
|
||||||
|
sec.localToCanvasPoint(sec.datas.points[i + 1]),
|
||||||
|
p
|
||||||
|
);
|
||||||
|
if (onLine && d < minD) {
|
||||||
|
minD = d;
|
||||||
|
deviceId = sec.id;
|
||||||
|
deviceType = sec.type;
|
||||||
|
port = SectionPort.A;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (deviceId) {
|
||||||
|
this.datas.refDev = createRelatedRefProto(deviceType, deviceId, port);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StopPositionTemplate extends JlGraphicTemplate<StopPosition> {
|
export class StopPositionTemplate extends JlGraphicTemplate<StopPosition> {
|
||||||
|
Loading…
Reference in New Issue
Block a user