列车添加公里标转换
This commit is contained in:
parent
d742c4c569
commit
04b7391fe1
@ -24,6 +24,7 @@ import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
|
||||
import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
import { state } from 'src/protos/device_state';
|
||||
import { getKmDistance } from '../lineScene';
|
||||
|
||||
export class SectionData extends GraphicDataBase implements ISectionData {
|
||||
constructor(data?: graphicData.Section) {
|
||||
@ -229,21 +230,21 @@ export class SectionOperateInteraction extends GraphicInteractionPlugin<Section>
|
||||
section,
|
||||
AxleCounting.Type
|
||||
);
|
||||
let A = 0;
|
||||
let B = 0;
|
||||
let AKm;
|
||||
let BKm;
|
||||
if (relations.length == 2) {
|
||||
relations.forEach((item) => {
|
||||
const rp = item.getRelationParam(section);
|
||||
const other = item.getOtherGraphic(section) as AxleCounting;
|
||||
if (rp.getParam() == 'A') {
|
||||
A = other.datas.kilometerSystem.kilometer;
|
||||
AKm = other.datas.kilometerSystem;
|
||||
}
|
||||
if (rp.getParam() == 'B') {
|
||||
B = other.datas.kilometerSystem.kilometer;
|
||||
BKm = other.datas.kilometerSystem;
|
||||
}
|
||||
});
|
||||
}
|
||||
const d = Math.abs(B - A);
|
||||
const d = getKmDistance(BKm, AKm);
|
||||
Dialog.create({
|
||||
title: '创建列车',
|
||||
message: '',
|
||||
|
@ -30,6 +30,7 @@ import { successNotify } from 'src/utils/CommonNotify';
|
||||
import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting';
|
||||
import { request } from 'src/protos/request';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
import { getKmDistance } from '../lineScene';
|
||||
|
||||
function getDefaultEndPoint() {
|
||||
return {
|
||||
@ -122,11 +123,11 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> {
|
||||
const rp = item.getRelationParam(turnout);
|
||||
return rp.getParam() == port;
|
||||
});
|
||||
const o = turnout.datas.kilometerSystem[0].kilometer;
|
||||
let p = 0;
|
||||
const oKm = turnout.datas.kilometerSystem[0];
|
||||
let pKm;
|
||||
if (findAc) {
|
||||
const other = findAc.getOtherGraphic(turnout) as AxleCounting;
|
||||
p = other.datas.kilometerSystem.kilometer;
|
||||
pKm = other.datas.kilometerSystem;
|
||||
} else {
|
||||
const relations =
|
||||
turnout.relationManage.getRelationsOfGraphicAndOtherType(
|
||||
@ -139,10 +140,10 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> {
|
||||
});
|
||||
if (findT) {
|
||||
const other = findT.getOtherGraphic(turnout) as Turnout;
|
||||
p = other.datas.kilometerSystem[0].kilometer;
|
||||
pKm = other.datas.kilometerSystem[0];
|
||||
}
|
||||
}
|
||||
const d = Math.abs(p - o);
|
||||
const d = getKmDistance(pKm, oKm);
|
||||
Dialog.create({
|
||||
title: '创建列车',
|
||||
message: '',
|
||||
|
@ -14,7 +14,11 @@ import {
|
||||
SignalOperateInteraction,
|
||||
SignalState,
|
||||
} from './graphics/SignalInteraction';
|
||||
import { SignalTemplate, Signal } from 'src/graphics/signal/Signal';
|
||||
import {
|
||||
SignalTemplate,
|
||||
Signal,
|
||||
KilometerSystem,
|
||||
} from 'src/graphics/signal/Signal';
|
||||
import {
|
||||
PlatformData,
|
||||
PlatformOperateInteraction,
|
||||
@ -270,6 +274,9 @@ export function initLineScene(lineApp: IGraphicApp, sceneName: string) {
|
||||
ControlShowType(lineScene);
|
||||
handleSubscribe(lineScene);
|
||||
});
|
||||
lineApp.on('destroy', () => {
|
||||
kilometerConvertMap.clear();
|
||||
});
|
||||
}
|
||||
|
||||
function handleSubscribe(lineScene: IGraphicScene) {
|
||||
@ -419,6 +426,7 @@ export async function loadLineDatas(): Promise<IGraphicStorage> {
|
||||
);
|
||||
console.log('加载数据', storage);
|
||||
// app.updateCanvas(storage.canvas);
|
||||
kilometerConvertMap.set(lineStore.sceneName, storage.kilometerConvertList);
|
||||
|
||||
const datas: GraphicData[] = [];
|
||||
storage.Platforms.forEach((platform) => {
|
||||
@ -507,3 +515,49 @@ export async function loadLineDatas(): Promise<IGraphicStorage> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const kilometerConvertMap: Map<string, graphicData.KilometerConvert[]> =
|
||||
new Map();
|
||||
export function getKmDistance(
|
||||
km1?: KilometerSystem,
|
||||
km2?: KilometerSystem
|
||||
): number {
|
||||
let d = 0;
|
||||
if (!km1 || !km2) {
|
||||
return 0;
|
||||
}
|
||||
if (km1.coordinateSystem == km2.coordinateSystem) {
|
||||
d = Math.abs(km1.kilometer - km2.kilometer);
|
||||
} else {
|
||||
const lineStore = useLineStore();
|
||||
const kmSystemList = kilometerConvertMap.get(lineStore.sceneName);
|
||||
const find = kmSystemList?.find((item) => {
|
||||
return (
|
||||
(item.kmA.coordinateSystem == km1.coordinateSystem &&
|
||||
item.kmB.coordinateSystem == km2.coordinateSystem) ||
|
||||
(item.kmA.coordinateSystem == km2.coordinateSystem &&
|
||||
item.kmB.coordinateSystem == km1.coordinateSystem)
|
||||
);
|
||||
});
|
||||
if (find) {
|
||||
const isA = find.kmA.coordinateSystem == km1.coordinateSystem;
|
||||
let m1;
|
||||
let m2;
|
||||
if (isA) {
|
||||
m1 = km1.kilometer - find.kmA.kilometer;
|
||||
m2 = km2.kilometer - find.kmB.kilometer;
|
||||
} else {
|
||||
m1 = km1.kilometer - find.kmB.kilometer;
|
||||
m2 = km2.kilometer - find.kmA.kilometer;
|
||||
}
|
||||
if (find.sameTrend) {
|
||||
d = Math.abs(m1 - m2);
|
||||
} else {
|
||||
d = Math.abs(m1 + m2);
|
||||
}
|
||||
} else {
|
||||
console.log('没有找到对应的公里标转换');
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ export function initRelayScene(lineApp: IGraphicApp, sceneName: string) {
|
||||
relay.refDevice.text = map.get(relay.id)?.replace(/_/g, '\n') as string;
|
||||
});
|
||||
});
|
||||
relayScene.on('destroy', () => {
|
||||
lineApp.on('destroy', () => {
|
||||
refRelaysList = [];
|
||||
});
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import { Turnout, TurnoutPort } from '../turnout/Turnout';
|
||||
import { Section } from '../section/Section';
|
||||
import { AxleCounting } from '../axleCounting/AxleCounting';
|
||||
import { state } from 'src/protos/device_state';
|
||||
import { getKmDistance } from 'src/drawApp/lineScene';
|
||||
|
||||
export interface ITrainData extends GraphicData {
|
||||
get code(): string; // 车号
|
||||
@ -346,11 +347,11 @@ export class Train extends JlGraphic {
|
||||
const rp = item.getRelationParam(dev as Turnout);
|
||||
return rp.getParam() == this.states.devicePort;
|
||||
});
|
||||
const o = dev.datas.kilometerSystem[0].kilometer;
|
||||
let p = 0;
|
||||
const oKm = dev.datas.kilometerSystem[0];
|
||||
let pKm;
|
||||
if (findAc) {
|
||||
const other = findAc.getOtherGraphic(dev) as AxleCounting;
|
||||
p = other.datas.kilometerSystem.kilometer;
|
||||
pKm = other.datas.kilometerSystem;
|
||||
} else {
|
||||
const relations = dev.relationManage.getRelationsOfGraphicAndOtherType(
|
||||
dev,
|
||||
@ -362,10 +363,10 @@ export class Train extends JlGraphic {
|
||||
});
|
||||
if (findT) {
|
||||
const other = findT.getOtherGraphic(dev) as Turnout;
|
||||
p = other.datas.kilometerSystem[0].kilometer;
|
||||
pKm = other.datas.kilometerSystem[0];
|
||||
}
|
||||
}
|
||||
allLength = Math.abs(p - o);
|
||||
allLength = getKmDistance(pKm, oKm);
|
||||
const portP = points[points.length - 1];
|
||||
const j = 10;
|
||||
if (Math.abs(portP.x) < j) {
|
||||
@ -387,8 +388,8 @@ export class Train extends JlGraphic {
|
||||
dev,
|
||||
AxleCounting.Type
|
||||
);
|
||||
let A = 0;
|
||||
let B = 0;
|
||||
let AKm;
|
||||
let BKm;
|
||||
let hasA = false;
|
||||
let hasB = false;
|
||||
// 获取区段A、B端的公里标,计算区段总度
|
||||
@ -396,16 +397,16 @@ export class Train extends JlGraphic {
|
||||
const rp = item.getRelationParam(dev as Section);
|
||||
const other = item.getOtherGraphic(dev as Section) as AxleCounting;
|
||||
if (rp.getParam() == 'A') {
|
||||
A = other.datas.kilometerSystem.kilometer;
|
||||
AKm = other.datas.kilometerSystem;
|
||||
hasA = true;
|
||||
}
|
||||
if (rp.getParam() == 'B') {
|
||||
B = other.datas.kilometerSystem.kilometer;
|
||||
BKm = other.datas.kilometerSystem;
|
||||
hasB = true;
|
||||
}
|
||||
});
|
||||
if (hasA && hasB) {
|
||||
allLength = Math.abs(B - A);
|
||||
allLength = getKmDistance(BKm, AKm);
|
||||
const portS = points[0];
|
||||
const portE = points[points.length - 1];
|
||||
this.isSyntropy = portE.x > portS.x;
|
||||
|
Loading…
Reference in New Issue
Block a user