添加列车移除列车
This commit is contained in:
parent
76733a8b26
commit
67f65c36bd
@ -1 +1 @@
|
|||||||
Subproject commit 5ead82f5bfc0fe13025cfc89d4a825c4a3105565
|
Subproject commit 0e8a73e1028177059ac306ca0c5abb8c52c2b3e2
|
@ -19,3 +19,30 @@ export async function destroySimulation(data: { simulationId: string }) {
|
|||||||
const response = await api.post(`${UriBase}/destroy`, data);
|
const response = await api.post(`${UriBase}/destroy`, data);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加列车
|
||||||
|
* @param simulationId 仿真id
|
||||||
|
* @param up 是否上行
|
||||||
|
* @param headLinkId 车头link索引
|
||||||
|
* @param headLinkOffset 车头link偏移
|
||||||
|
*/
|
||||||
|
export async function addTrain(data: {
|
||||||
|
simulationId: string;
|
||||||
|
up: boolean;
|
||||||
|
headLinkId: string;
|
||||||
|
headLinkOffset: number;
|
||||||
|
}) {
|
||||||
|
const response = await api.post(`${UriBase}/train/add`, data);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export async function removeTrain(data: {
|
||||||
|
simulationId: string;
|
||||||
|
trainId: string;
|
||||||
|
}) {
|
||||||
|
const response = await api.post(`${UriBase}/train/remove`, data);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
@ -58,7 +58,6 @@ const props = defineProps({
|
|||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const dir = ref(1);
|
const dir = ref(1);
|
||||||
const offset = ref(0);
|
const offset = ref(0);
|
||||||
const dirOptions = [
|
const dirOptions = [
|
||||||
|
@ -3,8 +3,8 @@ function getHost(): string {
|
|||||||
// return '192.168.3.47:9091';
|
// return '192.168.3.47:9091';
|
||||||
// return '192.168.3.37:9091';
|
// return '192.168.3.37:9091';
|
||||||
// return '192.168.3.15:9091';
|
// return '192.168.3.15:9091';
|
||||||
// return '192.168.3.5:9091';
|
return '192.168.3.5:9091';
|
||||||
return '192.168.3.233:9091';
|
// return '192.168.3.233:9091';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getHttpBase() {
|
export function getHttpBase() {
|
||||||
|
@ -13,10 +13,11 @@ import {
|
|||||||
} from 'src/jl-graphic';
|
} from 'src/jl-graphic';
|
||||||
import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
|
import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
|
||||||
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
|
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
|
||||||
import { SignalOperateInteraction } from './SignalInteraction';
|
|
||||||
import { Dialog } from 'quasar';
|
import { Dialog } from 'quasar';
|
||||||
import AddTrainDialog from '../../components/draw-app/dialogs/AddTrainDialog.vue';
|
import AddTrainDialog from '../../components/draw-app/dialogs/AddTrainDialog.vue';
|
||||||
|
import { addTrain } from 'src/api/Simulation';
|
||||||
|
import { useLineStore } from 'src/stores/line-store';
|
||||||
|
import { successNotify, errorNotify } from '../../utils/CommonNotify';
|
||||||
export class SectionLinkData
|
export class SectionLinkData
|
||||||
extends GraphicDataBase
|
extends GraphicDataBase
|
||||||
implements ISectionLinkData
|
implements ISectionLinkData
|
||||||
@ -114,7 +115,7 @@ export class SectionLinkOperateInteraction extends GraphicInteractionPlugin<Sect
|
|||||||
app.registerMenu(SectionLinkOperateMenu);
|
app.registerMenu(SectionLinkOperateMenu);
|
||||||
}
|
}
|
||||||
static init(app: GraphicApp) {
|
static init(app: GraphicApp) {
|
||||||
return new SignalOperateInteraction(app);
|
return new SectionLinkOperateInteraction(app);
|
||||||
}
|
}
|
||||||
filter(...grahpics: JlGraphic[]): SectionLink[] | undefined {
|
filter(...grahpics: JlGraphic[]): SectionLink[] | undefined {
|
||||||
return grahpics
|
return grahpics
|
||||||
@ -138,17 +139,31 @@ export class SectionLinkOperateInteraction extends GraphicInteractionPlugin<Sect
|
|||||||
const target = e.target as DisplayObject;
|
const target = e.target as DisplayObject;
|
||||||
const link = target.getGraphic() as SectionLink;
|
const link = target.getGraphic() as SectionLink;
|
||||||
this.app.updateSelected(link);
|
this.app.updateSelected(link);
|
||||||
|
const lineStore = useLineStore();
|
||||||
|
const simulationId = lineStore.simulationId || '';
|
||||||
addTrainConfig.handler = () => {
|
addTrainConfig.handler = () => {
|
||||||
Dialog.create({
|
Dialog.create({
|
||||||
title: '创建列车',
|
title: '创建列车',
|
||||||
message: '',
|
message: '',
|
||||||
component: AddTrainDialog,
|
component: AddTrainDialog,
|
||||||
componentProps: link.datas.index,
|
componentProps: { linkIndex: link.datas.index },
|
||||||
cancel: true,
|
cancel: true,
|
||||||
persistent: true,
|
persistent: true,
|
||||||
}).onOk((data: { offset: number; dir: 1 | 0 }) => {
|
}).onOk((data: { offset: number; dir: 1 | 0 }) => {
|
||||||
console.log(data, 'data');
|
addTrain({
|
||||||
|
simulationId,
|
||||||
|
up: !!data.dir,
|
||||||
|
headLinkId: link.datas.index.toString(),
|
||||||
|
headLinkOffset: data.offset,
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
successNotify('添加列车成功!');
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
errorNotify('添加列车失败!', err);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
SectionLinkOperateMenu.open(e.global);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import * as pb_1 from 'google-protobuf';
|
import * as pb_1 from 'google-protobuf';
|
||||||
import { ITrainState, Train } from 'src/graphics/train/Train';
|
import { ITrainState, Train } from 'src/graphics/train/Train';
|
||||||
import { GraphicStateBase } from './GraphicDataBase';
|
import { GraphicStateBase } from './GraphicDataBase';
|
||||||
import { state } from 'src/protos/device_status';
|
import { state } from 'src/protos/device_state';
|
||||||
import { train } from 'src/protos/train';
|
|
||||||
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
|
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
|
||||||
import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
|
import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
|
||||||
import {
|
import {
|
||||||
@ -11,169 +10,69 @@ import {
|
|||||||
JlGraphic,
|
JlGraphic,
|
||||||
} from 'src/jl-graphic';
|
} from 'src/jl-graphic';
|
||||||
import { DisplayObject, FederatedMouseEvent } from 'pixi.js';
|
import { DisplayObject, FederatedMouseEvent } from 'pixi.js';
|
||||||
|
import { removeTrain } from 'src/api/Simulation';
|
||||||
|
import { useLineStore } from 'src/stores/line-store';
|
||||||
|
import { successNotify, errorNotify } from '../../utils/CommonNotify';
|
||||||
export class TrainState extends GraphicStateBase implements ITrainState {
|
export class TrainState extends GraphicStateBase implements ITrainState {
|
||||||
constructor(proto?: train.TrainInfo) {
|
constructor(proto?: state.TrainState) {
|
||||||
let states;
|
let states;
|
||||||
if (proto) {
|
if (proto) {
|
||||||
states = proto;
|
states = proto;
|
||||||
} else {
|
} else {
|
||||||
states = new train.TrainInfo();
|
states = new state.TrainState();
|
||||||
}
|
}
|
||||||
super(states, Train.Type);
|
super(states, Train.Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
get code(): string {
|
get code(): string {
|
||||||
return this.states.trainIndex;
|
return this.states.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
get states(): train.TrainInfo {
|
get states(): state.TrainState {
|
||||||
return this.getState<train.TrainInfo>();
|
return this.getState<state.TrainState>();
|
||||||
}
|
}
|
||||||
|
|
||||||
get lineId(): number {
|
get id(): string {
|
||||||
return this.states.lineId;
|
return this.states.id;
|
||||||
}
|
}
|
||||||
set lineId(v: number) {
|
set id(v: string) {
|
||||||
this.states.lineId = v;
|
this.states.id = v;
|
||||||
}
|
}
|
||||||
get rtuId(): number {
|
get up(): boolean {
|
||||||
return this.states.rtuId;
|
return this.states.up;
|
||||||
}
|
}
|
||||||
set rtuId(v: number) {
|
set up(v: boolean) {
|
||||||
this.states.rtuId = v;
|
this.states.up = v;
|
||||||
}
|
}
|
||||||
get window(): train.NccWindow {
|
get headLinkId(): string {
|
||||||
if (!this.states.window) {
|
return this.states.headLinkId;
|
||||||
this.states.window = new train.NccWindow();
|
|
||||||
}
|
}
|
||||||
return this.states.window;
|
set headLinkId(v: string) {
|
||||||
|
this.states.headLinkId = v;
|
||||||
}
|
}
|
||||||
set window(v: train.NccWindow) {
|
get headLinkOffset(): number {
|
||||||
this.states.window = v;
|
return this.states.headLinkOffset;
|
||||||
}
|
}
|
||||||
get devType(): number {
|
set headLinkOffset(v: number) {
|
||||||
return this.states.devType;
|
this.states.headLinkOffset = v;
|
||||||
}
|
}
|
||||||
set devType(v: number) {
|
get tailLinkId(): string {
|
||||||
this.states.devType = v;
|
return this.states.tailLinkId;
|
||||||
}
|
}
|
||||||
get devName(): string {
|
set tailLinkId(v: string) {
|
||||||
return this.states.devName;
|
this.states.tailLinkId = v;
|
||||||
}
|
}
|
||||||
set devName(v: string) {
|
get tailLinkOffset(): number {
|
||||||
this.states.devName = v;
|
return this.states.tailLinkOffset;
|
||||||
}
|
}
|
||||||
get trainIndex(): string {
|
set tailLinkOffset(v: number) {
|
||||||
return this.states.trainIndex;
|
this.states.tailLinkOffset = v;
|
||||||
}
|
}
|
||||||
set trainIndex(v: string) {
|
get occupiedLinkIndex(): string[] {
|
||||||
this.states.trainIndex = v;
|
return this.states.occupiedLinkIndex;
|
||||||
}
|
}
|
||||||
get groupId(): string {
|
set occupiedLinkIndex(v: string[]) {
|
||||||
return this.states.groupId;
|
this.states.occupiedLinkIndex = v;
|
||||||
}
|
|
||||||
set groupId(v: string) {
|
|
||||||
this.states.groupId = v;
|
|
||||||
}
|
|
||||||
get trainId(): string {
|
|
||||||
return this.states.trainId;
|
|
||||||
}
|
|
||||||
set trainId(v: string) {
|
|
||||||
this.states.trainId = v;
|
|
||||||
}
|
|
||||||
get globalId(): string {
|
|
||||||
return this.states.globalId;
|
|
||||||
}
|
|
||||||
set globalId(v: string) {
|
|
||||||
this.states.globalId = v;
|
|
||||||
}
|
|
||||||
get destinationId(): number {
|
|
||||||
return this.states.destinationId;
|
|
||||||
}
|
|
||||||
set destinationId(v: number) {
|
|
||||||
this.states.destinationId = v;
|
|
||||||
}
|
|
||||||
get rollingStock(): number {
|
|
||||||
return this.states.rollingStock;
|
|
||||||
}
|
|
||||||
set rollingStock(v: number) {
|
|
||||||
this.states.rollingStock = v;
|
|
||||||
}
|
|
||||||
get driverId(): string {
|
|
||||||
return this.states.driverId;
|
|
||||||
}
|
|
||||||
set driverId(v: string) {
|
|
||||||
this.states.driverId = v;
|
|
||||||
}
|
|
||||||
get otpTime(): number {
|
|
||||||
return this.states.otpTime;
|
|
||||||
}
|
|
||||||
set otpTime(v: number) {
|
|
||||||
this.states.otpTime = v;
|
|
||||||
}
|
|
||||||
get mode(): state.TrainMode {
|
|
||||||
if (!this.states.mode) {
|
|
||||||
this.states.mode = new state.TrainMode();
|
|
||||||
}
|
|
||||||
return this.states.mode;
|
|
||||||
}
|
|
||||||
set mode(v: state.TrainMode) {
|
|
||||||
this.states.mode = v;
|
|
||||||
}
|
|
||||||
get arriveTime(): number {
|
|
||||||
return this.states.arriveTime;
|
|
||||||
}
|
|
||||||
set arriveTime(v: number) {
|
|
||||||
this.states.arriveTime = v;
|
|
||||||
}
|
|
||||||
get departTime(): number {
|
|
||||||
return this.states.departTime;
|
|
||||||
}
|
|
||||||
set departTime(v: number) {
|
|
||||||
this.states.departTime = v;
|
|
||||||
}
|
|
||||||
get speed(): number {
|
|
||||||
return this.states.speed;
|
|
||||||
}
|
|
||||||
set speed(v: number) {
|
|
||||||
this.states.speed = v;
|
|
||||||
}
|
|
||||||
get type(): boolean {
|
|
||||||
return this.states.type;
|
|
||||||
}
|
|
||||||
set type(v: boolean) {
|
|
||||||
this.states.type = v;
|
|
||||||
}
|
|
||||||
get routeId(): number {
|
|
||||||
return this.states.routeId;
|
|
||||||
}
|
|
||||||
set routeId(v: number) {
|
|
||||||
this.states.routeId = v;
|
|
||||||
}
|
|
||||||
get rate(): number {
|
|
||||||
return this.states.rate;
|
|
||||||
}
|
|
||||||
set rate(v: number) {
|
|
||||||
this.states.rate = v;
|
|
||||||
}
|
|
||||||
get remove(): train.TrainRemove {
|
|
||||||
return this.states.remove;
|
|
||||||
}
|
|
||||||
set remove(v: train.TrainRemove) {
|
|
||||||
this.states.remove = v;
|
|
||||||
}
|
|
||||||
get block(): train.TrainBlock {
|
|
||||||
return this.states.block;
|
|
||||||
}
|
|
||||||
set block(v: train.TrainBlock) {
|
|
||||||
this.states.block = v;
|
|
||||||
}
|
|
||||||
get record(): train.TrainRecord {
|
|
||||||
return this.states.record;
|
|
||||||
}
|
|
||||||
set record(v: train.TrainRecord) {
|
|
||||||
this.states.record = v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clone(): TrainState {
|
clone(): TrainState {
|
||||||
@ -187,40 +86,14 @@ export class TrainState extends GraphicStateBase implements ITrainState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const negativeDirectionConfig: MenuItemOptions = {
|
const removeTrainConfig: MenuItemOptions = {
|
||||||
name: '反方向运行',
|
name: '清除列车',
|
||||||
};
|
|
||||||
const runStopConfig: MenuItemOptions = {
|
|
||||||
name: '前进/停止',
|
|
||||||
};
|
|
||||||
const diriveModelConfig: MenuItemOptions = {
|
|
||||||
name: '驾驶模式',
|
|
||||||
};
|
|
||||||
const accuracyConfig: MenuItemOptions = {
|
|
||||||
name: '正常/早点/晚点',
|
|
||||||
};
|
|
||||||
const HoldTrainConfig: MenuItemOptions = {
|
|
||||||
name: '扣车',
|
|
||||||
};
|
|
||||||
const openDoorConfig: MenuItemOptions = {
|
|
||||||
name: '开门',
|
|
||||||
};
|
|
||||||
const editGroupConfig: MenuItemOptions = {
|
|
||||||
name: '修改车组号',
|
|
||||||
};
|
};
|
||||||
const TrainOperateMenu: ContextMenu = ContextMenu.init({
|
const TrainOperateMenu: ContextMenu = ContextMenu.init({
|
||||||
name: '列车操作菜单',
|
name: '列车操作菜单',
|
||||||
groups: [
|
groups: [
|
||||||
{
|
{
|
||||||
items: [
|
items: [removeTrainConfig],
|
||||||
negativeDirectionConfig,
|
|
||||||
runStopConfig,
|
|
||||||
diriveModelConfig,
|
|
||||||
accuracyConfig,
|
|
||||||
HoldTrainConfig,
|
|
||||||
openDoorConfig,
|
|
||||||
editGroupConfig,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@ -254,84 +127,21 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin<Train> {
|
|||||||
const target = e.target as DisplayObject;
|
const target = e.target as DisplayObject;
|
||||||
const train = target.getGraphic() as Train;
|
const train = target.getGraphic() as Train;
|
||||||
this.app.updateSelected(train);
|
this.app.updateSelected(train);
|
||||||
negativeDirectionConfig.handler = () => {
|
const lineStore = useLineStore();
|
||||||
const mode = train.states.mode;
|
const simulationId = lineStore.simulationId || '';
|
||||||
if (!train.states.mode.ipModeTrainDirUp) {
|
removeTrainConfig.handler = () => {
|
||||||
mode.ipModeTrainDirUp = true;
|
removeTrain({
|
||||||
mode.ipModeTrainDirDown = false;
|
simulationId,
|
||||||
} else if (!train.states.mode.ipModeTrainDirDown) {
|
trainId: train.code,
|
||||||
mode.ipModeTrainDirUp = false;
|
})
|
||||||
mode.ipModeTrainDirDown = true;
|
.then(() => {
|
||||||
}
|
successNotify('移除列车成功!');
|
||||||
train.doRepaint();
|
})
|
||||||
};
|
.catch((err) => {
|
||||||
runStopConfig.handler = () => {
|
errorNotify('移除列车失败!', err);
|
||||||
train.states.mode.ipModeTrainStoped =
|
|
||||||
!train.states.mode.ipModeTrainStoped;
|
|
||||||
train.doRepaint();
|
|
||||||
};
|
|
||||||
diriveModelConfig.handler = () => {
|
|
||||||
const arr: Array<keyof state.TrainMode> = [
|
|
||||||
'ipModeTrainDriveModeAm',
|
|
||||||
'ipModeTrainDriveModeCm',
|
|
||||||
'ipModeTrainDriveBlockAm',
|
|
||||||
'ipModeTrainDriveBlockCm',
|
|
||||||
'ipModeTrainDriveModeRmf',
|
|
||||||
];
|
|
||||||
let findIndex = arr.findIndex((key) => {
|
|
||||||
return train.states.mode[key];
|
|
||||||
});
|
});
|
||||||
if (findIndex == arr.length - 1) {
|
|
||||||
findIndex = -1;
|
|
||||||
}
|
|
||||||
arr.forEach((key) => {
|
|
||||||
(train.states.mode[key] as boolean) = false;
|
|
||||||
});
|
|
||||||
(train.states.mode[arr[findIndex + 1]] as boolean) = true;
|
|
||||||
train.doRepaint();
|
|
||||||
};
|
|
||||||
HoldTrainConfig.handler = () => {
|
|
||||||
train.states.mode.ipModeTrainHolded =
|
|
||||||
!train.states.mode.ipModeTrainHolded;
|
|
||||||
train.doRepaint();
|
|
||||||
};
|
|
||||||
accuracyConfig.handler = () => {
|
|
||||||
const arr: Array<keyof state.TrainMode> = [
|
|
||||||
'ipModeTrainTypeSchedule',
|
|
||||||
'ipModeTrainSchdEarly',
|
|
||||||
'ipModeTrainSchdLate',
|
|
||||||
];
|
|
||||||
let findIndex = -1;
|
|
||||||
arr.forEach((key, index) => {
|
|
||||||
if (train.states.mode[key]) {
|
|
||||||
findIndex = index;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
arr.forEach((key, index) => {
|
|
||||||
if (index != 0) {
|
|
||||||
(train.states.mode[key] as boolean) = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (findIndex != arr.length - 1) {
|
|
||||||
train.states.mode.ipModeTrainTypeSchedule = true;
|
|
||||||
}
|
|
||||||
if (findIndex == arr.length - 1) {
|
|
||||||
train.states.mode.ipModeTrainTypeSchedule = false;
|
|
||||||
} else {
|
|
||||||
(train.states.mode[arr[findIndex + 1]] as boolean) = true;
|
|
||||||
}
|
|
||||||
train.doRepaint();
|
|
||||||
};
|
|
||||||
openDoorConfig.handler = () => {
|
|
||||||
train.states.mode.ipModeTrainDoorOpen =
|
|
||||||
!train.states.mode.ipModeTrainDoorOpen;
|
|
||||||
train.doRepaint();
|
|
||||||
};
|
|
||||||
editGroupConfig.handler = () => {
|
|
||||||
train.states.trainId = '02';
|
|
||||||
train.states.destinationId = 123;
|
|
||||||
train.doRepaint();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TrainOperateMenu.open(e.global);
|
TrainOperateMenu.open(e.global);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -430,9 +430,17 @@ export async function loadDrawDatas(app: GraphicApp) {
|
|||||||
datas.push(new SeparatorData(separator));
|
datas.push(new SeparatorData(separator));
|
||||||
});
|
});
|
||||||
storage.sectionLinks.forEach((sectionLink) => {
|
storage.sectionLinks.forEach((sectionLink) => {
|
||||||
if (sectionLink.code) {
|
// if (sectionLink.code) {
|
||||||
sectionLink.index = parseInt(sectionLink.code);
|
// sectionLink.index = parseInt(sectionLink.code);
|
||||||
}
|
// }
|
||||||
|
// if (
|
||||||
|
// sectionLink.points[sectionLink.points.length - 1].x <
|
||||||
|
// sectionLink.points[0].x
|
||||||
|
// ) {
|
||||||
|
// console.log('1111111');
|
||||||
|
// const ps = [...sectionLink.points];
|
||||||
|
// sectionLink.points = ps.reverse();
|
||||||
|
// }
|
||||||
datas.push(new SectionLinkData(sectionLink));
|
datas.push(new SectionLinkData(sectionLink));
|
||||||
});
|
});
|
||||||
storage.axleCountingSections.forEach((axleCountingSection) => {
|
storage.axleCountingSections.forEach((axleCountingSection) => {
|
||||||
|
@ -6,7 +6,8 @@ import {
|
|||||||
GraphicState,
|
GraphicState,
|
||||||
} from 'src/jl-graphic';
|
} from 'src/jl-graphic';
|
||||||
import { TrainState } from './graphics/TrainInteraction';
|
import { TrainState } from './graphics/TrainInteraction';
|
||||||
import { TrainTemplate } from 'src/graphics/train/Train';
|
import { Train, TrainTemplate } from 'src/graphics/train/Train';
|
||||||
|
import { TrainOperateInteraction } from './graphics/TrainInteraction';
|
||||||
import {
|
import {
|
||||||
SignalData,
|
SignalData,
|
||||||
SignalOperateInteraction,
|
SignalOperateInteraction,
|
||||||
@ -54,7 +55,10 @@ import {
|
|||||||
} from 'src/graphics/sectionLink/SectionLink';
|
} from 'src/graphics/sectionLink/SectionLink';
|
||||||
import { Separator, SeparatorTemplate } from 'src/graphics/separator/Separator';
|
import { Separator, SeparatorTemplate } from 'src/graphics/separator/Separator';
|
||||||
import { SeparatorData } from './graphics/SeparatorInteraction';
|
import { SeparatorData } from './graphics/SeparatorInteraction';
|
||||||
import { SectionLinkData } from './graphics/SectionLinkInteraction';
|
import {
|
||||||
|
SectionLinkData,
|
||||||
|
SectionLinkOperateInteraction,
|
||||||
|
} from './graphics/SectionLinkInteraction';
|
||||||
import { AxleCountingSectionData } from './graphics/AxleCountingSectionInteraction';
|
import { AxleCountingSectionData } from './graphics/AxleCountingSectionInteraction';
|
||||||
import { LogicSectionData } from './graphics/LogicSectionInteraction';
|
import { LogicSectionData } from './graphics/LogicSectionInteraction';
|
||||||
|
|
||||||
@ -137,12 +141,16 @@ export function initLineApp(dom: HTMLElement): GraphicApp {
|
|||||||
Signal.Type,
|
Signal.Type,
|
||||||
Platform.Type,
|
Platform.Type,
|
||||||
Station.Type,
|
Station.Type,
|
||||||
|
SectionLink.Type,
|
||||||
|
Train.Type,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
SignalOperateInteraction.init(lineApp);
|
SignalOperateInteraction.init(lineApp);
|
||||||
PlatformOperateInteraction.init(lineApp);
|
PlatformOperateInteraction.init(lineApp);
|
||||||
StationOperateInteraction.init(lineApp);
|
StationOperateInteraction.init(lineApp);
|
||||||
|
SectionLinkOperateInteraction.init(lineApp);
|
||||||
|
TrainOperateInteraction.init(lineApp);
|
||||||
// 画布右键菜单
|
// 画布右键菜单
|
||||||
lineApp.registerMenu(DefaultCanvasMenu);
|
lineApp.registerMenu(DefaultCanvasMenu);
|
||||||
lineApp.canvas.on('_rightclick', (e) => {
|
lineApp.canvas.on('_rightclick', (e) => {
|
||||||
@ -164,6 +172,7 @@ export function initLineApp(dom: HTMLElement): GraphicApp {
|
|||||||
g.visible = false;
|
g.visible = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log(lineApp);
|
||||||
};
|
};
|
||||||
DefaultCanvasMenu.open(e.global);
|
DefaultCanvasMenu.open(e.global);
|
||||||
});
|
});
|
||||||
@ -215,9 +224,6 @@ export async function loadLineDatas(app: GraphicApp) {
|
|||||||
datas.push(new SeparatorData(separator));
|
datas.push(new SeparatorData(separator));
|
||||||
});
|
});
|
||||||
storage.sectionLinks.forEach((sectionLink) => {
|
storage.sectionLinks.forEach((sectionLink) => {
|
||||||
if (sectionLink.code) {
|
|
||||||
sectionLink.index = parseInt(sectionLink.code);
|
|
||||||
}
|
|
||||||
datas.push(new SectionLinkData(sectionLink));
|
datas.push(new SectionLinkData(sectionLink));
|
||||||
});
|
});
|
||||||
storage.axleCountingSections.forEach((axleCountingSection) => {
|
storage.axleCountingSections.forEach((axleCountingSection) => {
|
||||||
@ -247,6 +253,7 @@ export async function loadLineDatas(app: GraphicApp) {
|
|||||||
messageConverter: (message: Uint8Array) => {
|
messageConverter: (message: Uint8Array) => {
|
||||||
const states: GraphicState[] = [];
|
const states: GraphicState[] = [];
|
||||||
const storage = state.PushedDevicesStatus.deserialize(message);
|
const storage = state.PushedDevicesStatus.deserialize(message);
|
||||||
|
console.log(storage, 'storage');
|
||||||
if (storage.all) {
|
if (storage.all) {
|
||||||
storage.allStatus.sectionState.forEach((item) => {
|
storage.allStatus.sectionState.forEach((item) => {
|
||||||
if (state.SectionType[item.type] == 'Axle') {
|
if (state.SectionType[item.type] == 'Axle') {
|
||||||
@ -287,11 +294,14 @@ export async function loadLineDatas(app: GraphicApp) {
|
|||||||
});
|
});
|
||||||
storage.varStatus.updatedTrain.forEach((item) => {
|
storage.varStatus.updatedTrain.forEach((item) => {
|
||||||
// 列车
|
// 列车
|
||||||
// states.push(new TrainState(item));
|
states.push(new TrainState(item));
|
||||||
});
|
});
|
||||||
storage.varStatus.removedTrainId.forEach((item) => {
|
storage.varStatus.removedTrainId.forEach((item) => {
|
||||||
// 移除列车
|
// 移除列车
|
||||||
// states.push(new TrainState(item));
|
const train = app.queryStore.queryByCodeAndType(item, Train.Type);
|
||||||
|
if (train) {
|
||||||
|
app.deleteGraphics(train);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return states;
|
return states;
|
||||||
|
@ -61,6 +61,9 @@ export class AxleCountingSection extends JlGraphic {
|
|||||||
get datas(): IAxleCountingSectionData {
|
get datas(): IAxleCountingSectionData {
|
||||||
return this.getDatas<IAxleCountingSectionData>();
|
return this.getDatas<IAxleCountingSectionData>();
|
||||||
}
|
}
|
||||||
|
get code(): string {
|
||||||
|
return this.datas.index + '';
|
||||||
|
}
|
||||||
doRepaint(): void {
|
doRepaint(): void {
|
||||||
if (this.datas.points.length < 2) {
|
if (this.datas.points.length < 2) {
|
||||||
throw new Error('AxleCountingSection坐标数据异常');
|
throw new Error('AxleCountingSection坐标数据异常');
|
||||||
|
@ -57,6 +57,9 @@ export class LogicSection extends JlGraphic {
|
|||||||
get datas(): ILogicSectionData {
|
get datas(): ILogicSectionData {
|
||||||
return this.getDatas<ILogicSectionData>();
|
return this.getDatas<ILogicSectionData>();
|
||||||
}
|
}
|
||||||
|
get code(): string {
|
||||||
|
return this.datas.index + '';
|
||||||
|
}
|
||||||
doRepaint(): void {
|
doRepaint(): void {
|
||||||
if (this.datas.points.length < 2) {
|
if (this.datas.points.length < 2) {
|
||||||
throw new Error('LogicSection坐标数据异常');
|
throw new Error('LogicSection坐标数据异常');
|
||||||
|
@ -402,6 +402,9 @@ export class Platform extends JlGraphic {
|
|||||||
get states(): IPlatformState {
|
get states(): IPlatformState {
|
||||||
return this.getStates<IPlatformState>();
|
return this.getStates<IPlatformState>();
|
||||||
}
|
}
|
||||||
|
get code(): string {
|
||||||
|
return this.datas.index + '';
|
||||||
|
}
|
||||||
doRepaint(): void {
|
doRepaint(): void {
|
||||||
this.doorGraphic.clear();
|
this.doorGraphic.clear();
|
||||||
if (this.datas.hasdoor) {
|
if (this.datas.hasdoor) {
|
||||||
|
@ -123,6 +123,9 @@ export class Section extends JlGraphic implements ILineGraphic {
|
|||||||
get datas(): ISectionData {
|
get datas(): ISectionData {
|
||||||
return this.getDatas<ISectionData>();
|
return this.getDatas<ISectionData>();
|
||||||
}
|
}
|
||||||
|
get code(): string {
|
||||||
|
return this.datas.index + '';
|
||||||
|
}
|
||||||
|
|
||||||
get linePoints(): IPointData[] {
|
get linePoints(): IPointData[] {
|
||||||
return this.datas.points;
|
return this.datas.points;
|
||||||
|
@ -137,7 +137,9 @@ export class SectionLink extends JlGraphic implements ILineGraphic {
|
|||||||
get datas(): ISectionLinkData {
|
get datas(): ISectionLinkData {
|
||||||
return this.getDatas<ISectionLinkData>();
|
return this.getDatas<ISectionLinkData>();
|
||||||
}
|
}
|
||||||
|
get code(): string {
|
||||||
|
return this.datas.index + '';
|
||||||
|
}
|
||||||
get linePoints(): IPointData[] {
|
get linePoints(): IPointData[] {
|
||||||
return this.datas.points;
|
return this.datas.points;
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,9 @@ export class SectionLinkDraw extends GraphicDrawAssistant<
|
|||||||
} else {
|
} else {
|
||||||
throw new Error('无法判断linkAB端');
|
throw new Error('无法判断linkAB端');
|
||||||
}
|
}
|
||||||
|
if (points[points.length - 1].x < points[0].x) {
|
||||||
|
points.reverse();
|
||||||
|
}
|
||||||
sectionLink.datas.points = points;
|
sectionLink.datas.points = points;
|
||||||
return sectionLink;
|
return sectionLink;
|
||||||
}
|
}
|
||||||
@ -216,6 +219,9 @@ export class SectionLinkDraw extends GraphicDrawAssistant<
|
|||||||
points.push(turnout.localToCanvasPoint(dataPoint[pLength - i]));
|
points.push(turnout.localToCanvasPoint(dataPoint[pLength - i]));
|
||||||
}
|
}
|
||||||
points.push(forkP2);
|
points.push(forkP2);
|
||||||
|
if (points[points.length - 1].x < points[0].x) {
|
||||||
|
points.reverse();
|
||||||
|
}
|
||||||
sectionLink.datas.points = points;
|
sectionLink.datas.points = points;
|
||||||
return sectionLink;
|
return sectionLink;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,9 @@ export class Signal extends JlGraphic {
|
|||||||
get states(): ISignalState {
|
get states(): ISignalState {
|
||||||
return this.getStates<ISignalState>();
|
return this.getStates<ISignalState>();
|
||||||
}
|
}
|
||||||
|
get code(): string {
|
||||||
|
return this.datas.index + '';
|
||||||
|
}
|
||||||
get mirror(): boolean {
|
get mirror(): boolean {
|
||||||
return this.datas.mirror;
|
return this.datas.mirror;
|
||||||
}
|
}
|
||||||
|
@ -297,6 +297,9 @@ export class Station extends JlGraphic {
|
|||||||
get states(): IStationState {
|
get states(): IStationState {
|
||||||
return this.getStates<IStationState>();
|
return this.getStates<IStationState>();
|
||||||
}
|
}
|
||||||
|
get code(): string {
|
||||||
|
return this.datas.index + '';
|
||||||
|
}
|
||||||
doRepaint(): void {
|
doRepaint(): void {
|
||||||
const codeGraph = this.codeGraph;
|
const codeGraph = this.codeGraph;
|
||||||
const kilometerGraph = this.kilometerGraph;
|
const kilometerGraph = this.kilometerGraph;
|
||||||
|
@ -7,9 +7,9 @@ import {
|
|||||||
JlGraphicTemplate,
|
JlGraphicTemplate,
|
||||||
VectorText,
|
VectorText,
|
||||||
calculateMirrorPoint,
|
calculateMirrorPoint,
|
||||||
|
distance,
|
||||||
} from 'src/jl-graphic';
|
} from 'src/jl-graphic';
|
||||||
import { train } from 'src/protos/train';
|
import { SectionLink } from '../sectionLink/SectionLink';
|
||||||
import { state } from 'src/protos/device_status';
|
|
||||||
|
|
||||||
export interface ITrainData extends GraphicData {
|
export interface ITrainData extends GraphicData {
|
||||||
get code(): string; // 车号
|
get code(): string; // 车号
|
||||||
@ -20,52 +20,20 @@ export interface ITrainData extends GraphicData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ITrainState extends GraphicState {
|
export interface ITrainState extends GraphicState {
|
||||||
get lineId(): number; // 线路id
|
get id(): string; // 列车id
|
||||||
set lineId(v: number);
|
set id(v: string);
|
||||||
get rtuId(): number; // 集中站站号
|
get up(): boolean;
|
||||||
set rtuId(v: number);
|
set up(v: boolean);
|
||||||
get window(): train.NccWindow; // NccWindow
|
get headLinkId(): string; // 头部link位置
|
||||||
set window(v: train.NccWindow);
|
set headLinkId(v: string);
|
||||||
get devType(): state.DeviceType; // 所在设备类型
|
get headLinkOffset(): number;
|
||||||
set devType(v: state.DeviceType);
|
set headLinkOffset(v: number);
|
||||||
get devName(): string; // 所在设备名称
|
get tailLinkId(): string;
|
||||||
set devName(v: string);
|
set tailLinkId(v: string);
|
||||||
get trainIndex(): string; // 设备唯一,与trainIndex相同
|
get tailLinkOffset(): number;
|
||||||
set trainIndex(v: string);
|
set tailLinkOffset(v: number);
|
||||||
get groupId(): string; // 列车车组号
|
get occupiedLinkIndex(): string[];
|
||||||
set groupId(v: string);
|
set occupiedLinkIndex(v: string[]);
|
||||||
get trainId(): string; // 列车表号
|
|
||||||
set trainId(v: string);
|
|
||||||
get globalId(): string; // 列车车次号
|
|
||||||
set globalId(v: string);
|
|
||||||
get destinationId(): number; // 目的地ID
|
|
||||||
set destinationId(v: number);
|
|
||||||
get rollingStock(): number; // 编组数量
|
|
||||||
set rollingStock(v: number);
|
|
||||||
get driverId(): string; // 司机号
|
|
||||||
set driverId(v: string);
|
|
||||||
get otpTime(): number; // 计划偏离时间
|
|
||||||
set otpTime(v: number);
|
|
||||||
get mode(): state.TrainMode; // 列车状态
|
|
||||||
set mode(v: state.TrainMode);
|
|
||||||
get arriveTime(): number; // 到点
|
|
||||||
set arriveTime(v: number);
|
|
||||||
get departTime(): number; // 发点
|
|
||||||
set departTime(v: number);
|
|
||||||
get speed(): number; // 速度
|
|
||||||
set speed(v: number);
|
|
||||||
get type(): boolean; // 车次号变化状态
|
|
||||||
set type(v: boolean);
|
|
||||||
get routeId(): number; // 运行路径号
|
|
||||||
set routeId(v: number);
|
|
||||||
get rate(): number; // 满载率
|
|
||||||
set rate(v: number);
|
|
||||||
get remove(): train.TrainRemove;
|
|
||||||
set remove(v: train.TrainRemove);
|
|
||||||
get block(): train.TrainBlock;
|
|
||||||
set block(v: train.TrainBlock);
|
|
||||||
get record(): train.TrainRecord;
|
|
||||||
set record(v: train.TrainRecord);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface bodyWH {
|
interface bodyWH {
|
||||||
@ -136,13 +104,10 @@ export class TrainHead extends Container {
|
|||||||
this.pause.clear();
|
this.pause.clear();
|
||||||
}
|
}
|
||||||
doRepaint(states: ITrainState, bodyWH?: bodyWH) {
|
doRepaint(states: ITrainState, bodyWH?: bodyWH) {
|
||||||
let direction = '';
|
let direction = 'right';
|
||||||
if (states.mode?.ipModeTrainDirDown) {
|
if (states.up) {
|
||||||
direction = 'left';
|
direction = 'left';
|
||||||
}
|
}
|
||||||
if (states.mode?.ipModeTrainDirUp) {
|
|
||||||
direction = 'right';
|
|
||||||
}
|
|
||||||
this.clear();
|
this.clear();
|
||||||
if (!direction) {
|
if (!direction) {
|
||||||
return;
|
return;
|
||||||
@ -185,21 +150,8 @@ export class TrainHead extends Container {
|
|||||||
});
|
});
|
||||||
pausePoint = pP;
|
pausePoint = pP;
|
||||||
}
|
}
|
||||||
let aColor = DiriveModelColorEnum.AM;
|
const aColor = DiriveModelColorEnum.AM;
|
||||||
let pColor = DiriveModelColorEnum.AM;
|
const pColor = DiriveModelColorEnum.AM;
|
||||||
if (
|
|
||||||
states.mode?.ipModeTrainDriveModeCm ||
|
|
||||||
states.mode?.ipModeTrainDriveBlockCm
|
|
||||||
) {
|
|
||||||
aColor = DiriveModelColorEnum.SM;
|
|
||||||
pColor = DiriveModelColorEnum.SM;
|
|
||||||
} else if (
|
|
||||||
states.mode?.ipModeTrainDriveModeRmf ||
|
|
||||||
states.mode?.ipModeTrainDriveModeRmr
|
|
||||||
) {
|
|
||||||
aColor = DiriveModelColorEnum.RM;
|
|
||||||
pColor = DiriveModelColorEnum.RM;
|
|
||||||
}
|
|
||||||
this.pause.lineStyle(pauseW, pColor, 1);
|
this.pause.lineStyle(pauseW, pColor, 1);
|
||||||
this.pause.moveTo(pausePoint[0], pausePoint[1]);
|
this.pause.moveTo(pausePoint[0], pausePoint[1]);
|
||||||
this.pause.lineTo(pausePoint[2], pausePoint[3]);
|
this.pause.lineTo(pausePoint[2], pausePoint[3]);
|
||||||
@ -207,11 +159,11 @@ export class TrainHead extends Container {
|
|||||||
arrow.beginFill(aColor, 1);
|
arrow.beginFill(aColor, 1);
|
||||||
arrow.drawPolygon(arrowPoint);
|
arrow.drawPolygon(arrowPoint);
|
||||||
arrow.endFill();
|
arrow.endFill();
|
||||||
if (states.mode?.ipModeTrainStoped) {
|
// if (states.mode?.ipModeTrainStoped) {
|
||||||
this.arrow.visible = false;
|
// this.arrow.visible = false;
|
||||||
} else {
|
// } else {
|
||||||
this.arrow.visible = true;
|
// this.arrow.visible = true;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,45 +197,15 @@ export class TrainBody extends Container {
|
|||||||
const codeAGraph = this.codeAGraph;
|
const codeAGraph = this.codeAGraph;
|
||||||
const codeBGraph = this.codeBGraph;
|
const codeBGraph = this.codeBGraph;
|
||||||
const codeRact = this.codeRact;
|
const codeRact = this.codeRact;
|
||||||
const codeA = states?.groupId;
|
const codeA = states?.code;
|
||||||
let codeB = states?.destinationId ? states?.destinationId + '' : '';
|
|
||||||
const fillAColor = typeColorEnum.schedule;
|
const fillAColor = typeColorEnum.schedule;
|
||||||
let fillBColor = typeColorEnum.schedule;
|
codeAGraph.text = codeA || '';
|
||||||
if (states.mode?.ipModeTrainTypeSchedule) {
|
|
||||||
fillBColor = typeColorEnum.accuracy;
|
|
||||||
if (states.mode?.ipModeTrainSchdLate) {
|
|
||||||
fillBColor = typeColorEnum.late;
|
|
||||||
} else if (states.mode?.ipModeTrainSchdEarly) {
|
|
||||||
fillBColor = typeColorEnum.early;
|
|
||||||
}
|
|
||||||
} else if (states.mode?.ipModeTrainTypeHead) {
|
|
||||||
codeB = states?.destinationId ? states?.destinationId + '' : '';
|
|
||||||
} else if (states.mode?.ipModeTrainTypeManual) {
|
|
||||||
codeB = '---';
|
|
||||||
} else if (states.mode?.ipModeTrainTypeSpecial) {
|
|
||||||
codeB = 'MM';
|
|
||||||
}
|
|
||||||
let bgColor = TrainColorEnum.ITCbodyColor;
|
|
||||||
if (
|
|
||||||
states.mode?.ipModeTrainDriveModeAm ||
|
|
||||||
states.mode?.ipModeTrainDriveModeCm
|
|
||||||
) {
|
|
||||||
bgColor = TrainColorEnum.bodyColor;
|
|
||||||
}
|
|
||||||
codeAGraph.text = codeA || '01';
|
|
||||||
codeBGraph.text = codeB || '222';
|
|
||||||
codeAGraph.anchor.set(0.5);
|
codeAGraph.anchor.set(0.5);
|
||||||
codeBGraph.anchor.set(0.5);
|
|
||||||
const styleA = {
|
const styleA = {
|
||||||
fill: fillAColor,
|
fill: fillAColor,
|
||||||
fontSize: trainConsts.codeFontSize,
|
fontSize: trainConsts.codeFontSize,
|
||||||
};
|
};
|
||||||
const styleB = {
|
|
||||||
fill: fillBColor,
|
|
||||||
fontSize: trainConsts.codeFontSize,
|
|
||||||
};
|
|
||||||
codeAGraph.style = styleA;
|
codeAGraph.style = styleA;
|
||||||
codeBGraph.style = styleB;
|
|
||||||
const bodyAWH = codeAGraph.getLocalBounds();
|
const bodyAWH = codeAGraph.getLocalBounds();
|
||||||
const bodyBWH = codeBGraph.getLocalBounds();
|
const bodyBWH = codeBGraph.getLocalBounds();
|
||||||
codeAGraph.position.set(-bodyBWH.width / 2, 0);
|
codeAGraph.position.set(-bodyBWH.width / 2, 0);
|
||||||
@ -295,6 +217,7 @@ export class TrainBody extends Container {
|
|||||||
trainConsts.borderWidth,
|
trainConsts.borderWidth,
|
||||||
new Color(TrainColorEnum.borderColor)
|
new Color(TrainColorEnum.borderColor)
|
||||||
);
|
);
|
||||||
|
const bgColor = TrainColorEnum.ITCbodyColor;
|
||||||
codeRact.beginFill(new Color(bgColor));
|
codeRact.beginFill(new Color(bgColor));
|
||||||
codeRact.drawRect(-codeWidth / 2, -codeHeight / 2, codeWidth, codeHeight);
|
codeRact.drawRect(-codeWidth / 2, -codeHeight / 2, codeWidth, codeHeight);
|
||||||
codeRact.endFill();
|
codeRact.endFill();
|
||||||
@ -367,26 +290,51 @@ export class Train extends JlGraphic {
|
|||||||
this.trainbody.doRepaint(this.states);
|
this.trainbody.doRepaint(this.states);
|
||||||
const bodyWH = this.trainbody.getBodyWH();
|
const bodyWH = this.trainbody.getBodyWH();
|
||||||
this.trainHead.doRepaint(this.states, bodyWH);
|
this.trainHead.doRepaint(this.states, bodyWH);
|
||||||
if (this.states.mode?.ipModeTrainHolded) {
|
// this.position.set(0, 0);
|
||||||
this.showStatus('扣');
|
const link =
|
||||||
} else {
|
this.getGraphicApp().queryStore.queryByCodeAndType<SectionLink>(
|
||||||
this.hideStatus('扣');
|
this.states.headLinkId,
|
||||||
|
SectionLink.Type
|
||||||
|
);
|
||||||
|
if (!link) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (this.states.mode?.ipModeTrainSkipstop) {
|
const lengths = [];
|
||||||
this.showStatus('跳');
|
let totalLength = 0;
|
||||||
} else {
|
const points = [...link.datas.points];
|
||||||
this.hideStatus('跳');
|
for (let i = 0; i < points.length - 1; i++) {
|
||||||
|
const l = distance(
|
||||||
|
points[i].x,
|
||||||
|
points[i].y,
|
||||||
|
points[i + 1].x,
|
||||||
|
points[i + 1].y
|
||||||
|
);
|
||||||
|
lengths.push(l);
|
||||||
|
totalLength += l;
|
||||||
}
|
}
|
||||||
if (this.states.mode?.ipModeTrainDoorOpen) {
|
let offsetL = totalLength * this.states.headLinkOffset;
|
||||||
this.showStatus('门');
|
if (this.states.up) {
|
||||||
} else {
|
lengths.reverse();
|
||||||
this.hideStatus('门');
|
points.reverse();
|
||||||
}
|
}
|
||||||
if (this.states.mode?.ipModeTrainRsAlarm) {
|
const indexP = lengths.findIndex((l) => {
|
||||||
this.showStatus('警');
|
offsetL -= l;
|
||||||
|
return offsetL <= 0;
|
||||||
|
});
|
||||||
|
const startP = points[indexP];
|
||||||
|
const endP = points[indexP + 1];
|
||||||
|
const px =
|
||||||
|
startP.x + Math.round(this.states.headLinkOffset * (endP.x - startP.x));
|
||||||
|
const py =
|
||||||
|
startP.y + Math.round(this.states.headLinkOffset * (endP.y - startP.y));
|
||||||
|
let angle = 0;
|
||||||
|
if (this.states.up) {
|
||||||
|
angle = Math.atan2(startP.y - endP.y, startP.x - endP.x);
|
||||||
} else {
|
} else {
|
||||||
this.hideStatus('警');
|
angle = Math.atan2(endP.y - startP.y, endP.x - startP.x);
|
||||||
}
|
}
|
||||||
|
this.position.set(px, py);
|
||||||
|
this.rotation = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
showStatus(s: string) {
|
showStatus(s: string) {
|
||||||
|
@ -194,6 +194,10 @@ export class Turnout extends JlGraphic {
|
|||||||
return this.getStates<ITurnoutState>();
|
return this.getStates<ITurnoutState>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get code(): string {
|
||||||
|
return this.datas.index + '';
|
||||||
|
}
|
||||||
|
|
||||||
getPortPoints() {
|
getPortPoints() {
|
||||||
return [this.datas.pointA, this.datas.pointB, this.datas.pointC];
|
return [this.datas.pointA, this.datas.pointB, this.datas.pointC];
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ import { pageQuery, deletePublish } from '../api/PublishApi';
|
|||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { createSimulation } from 'src/api/Simulation';
|
import { createSimulation } from 'src/api/Simulation';
|
||||||
import { ApiError } from 'src/boot/axios';
|
import { ApiError } from 'src/boot/axios';
|
||||||
|
import { useLineStore } from 'src/stores/line-store';
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
|
|
||||||
@ -89,6 +90,7 @@ const columnDefs: QTableColumn[] = [
|
|||||||
|
|
||||||
const operateDisabled = ref(false);
|
const operateDisabled = ref(false);
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
|
const lineStore = useLineStore();
|
||||||
const rows = reactive([]);
|
const rows = reactive([]);
|
||||||
const filter = reactive({
|
const filter = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
@ -138,6 +140,7 @@ async function create(row: any) {
|
|||||||
mapId: res.mapId,
|
mapId: res.mapId,
|
||||||
simulationId: res.simulationId,
|
simulationId: res.simulationId,
|
||||||
};
|
};
|
||||||
|
lineStore.setSimulationId(res.simulationId);
|
||||||
router.push({ path: '/linemap', query });
|
router.push({ path: '/linemap', query });
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
@ -331,18 +331,22 @@ export namespace state {
|
|||||||
#one_of_decls: number[][] = [];
|
#one_of_decls: number[][] = [];
|
||||||
constructor(data?: any[] | {
|
constructor(data?: any[] | {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
up?: boolean;
|
||||||
headLinkId?: string;
|
headLinkId?: string;
|
||||||
headLinkOffset?: number;
|
headLinkOffset?: number;
|
||||||
tailLinkId?: string;
|
tailLinkId?: string;
|
||||||
tailLinkOffset?: number;
|
tailLinkOffset?: number;
|
||||||
occupiedLinkId?: string[];
|
occupiedLinkIndex?: string[];
|
||||||
}) {
|
}) {
|
||||||
super();
|
super();
|
||||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [6], this.#one_of_decls);
|
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [7], this.#one_of_decls);
|
||||||
if (!Array.isArray(data) && typeof data == "object") {
|
if (!Array.isArray(data) && typeof data == "object") {
|
||||||
if ("id" in data && data.id != undefined) {
|
if ("id" in data && data.id != undefined) {
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
}
|
}
|
||||||
|
if ("up" in data && data.up != undefined) {
|
||||||
|
this.up = data.up;
|
||||||
|
}
|
||||||
if ("headLinkId" in data && data.headLinkId != undefined) {
|
if ("headLinkId" in data && data.headLinkId != undefined) {
|
||||||
this.headLinkId = data.headLinkId;
|
this.headLinkId = data.headLinkId;
|
||||||
}
|
}
|
||||||
@ -355,8 +359,8 @@ export namespace state {
|
|||||||
if ("tailLinkOffset" in data && data.tailLinkOffset != undefined) {
|
if ("tailLinkOffset" in data && data.tailLinkOffset != undefined) {
|
||||||
this.tailLinkOffset = data.tailLinkOffset;
|
this.tailLinkOffset = data.tailLinkOffset;
|
||||||
}
|
}
|
||||||
if ("occupiedLinkId" in data && data.occupiedLinkId != undefined) {
|
if ("occupiedLinkIndex" in data && data.occupiedLinkIndex != undefined) {
|
||||||
this.occupiedLinkId = data.occupiedLinkId;
|
this.occupiedLinkIndex = data.occupiedLinkIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,48 +370,58 @@ export namespace state {
|
|||||||
set id(value: string) {
|
set id(value: string) {
|
||||||
pb_1.Message.setField(this, 1, value);
|
pb_1.Message.setField(this, 1, value);
|
||||||
}
|
}
|
||||||
get headLinkId() {
|
get up() {
|
||||||
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
|
return pb_1.Message.getFieldWithDefault(this, 2, false) as boolean;
|
||||||
}
|
}
|
||||||
set headLinkId(value: string) {
|
set up(value: boolean) {
|
||||||
pb_1.Message.setField(this, 2, value);
|
pb_1.Message.setField(this, 2, value);
|
||||||
}
|
}
|
||||||
get headLinkOffset() {
|
get headLinkId() {
|
||||||
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
|
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
|
||||||
}
|
}
|
||||||
set headLinkOffset(value: number) {
|
set headLinkId(value: string) {
|
||||||
pb_1.Message.setField(this, 3, value);
|
pb_1.Message.setField(this, 3, value);
|
||||||
}
|
}
|
||||||
get tailLinkId() {
|
get headLinkOffset() {
|
||||||
return pb_1.Message.getFieldWithDefault(this, 4, "") as string;
|
return pb_1.Message.getFieldWithDefault(this, 4, 0) as number;
|
||||||
}
|
}
|
||||||
set tailLinkId(value: string) {
|
set headLinkOffset(value: number) {
|
||||||
pb_1.Message.setField(this, 4, value);
|
pb_1.Message.setField(this, 4, value);
|
||||||
}
|
}
|
||||||
get tailLinkOffset() {
|
get tailLinkId() {
|
||||||
return pb_1.Message.getFieldWithDefault(this, 5, 0) as number;
|
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
|
||||||
}
|
}
|
||||||
set tailLinkOffset(value: number) {
|
set tailLinkId(value: string) {
|
||||||
pb_1.Message.setField(this, 5, value);
|
pb_1.Message.setField(this, 5, value);
|
||||||
}
|
}
|
||||||
get occupiedLinkId() {
|
get tailLinkOffset() {
|
||||||
return pb_1.Message.getFieldWithDefault(this, 6, []) as string[];
|
return pb_1.Message.getFieldWithDefault(this, 6, 0) as number;
|
||||||
}
|
}
|
||||||
set occupiedLinkId(value: string[]) {
|
set tailLinkOffset(value: number) {
|
||||||
pb_1.Message.setField(this, 6, value);
|
pb_1.Message.setField(this, 6, value);
|
||||||
}
|
}
|
||||||
|
get occupiedLinkIndex() {
|
||||||
|
return pb_1.Message.getFieldWithDefault(this, 7, []) as string[];
|
||||||
|
}
|
||||||
|
set occupiedLinkIndex(value: string[]) {
|
||||||
|
pb_1.Message.setField(this, 7, value);
|
||||||
|
}
|
||||||
static fromObject(data: {
|
static fromObject(data: {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
up?: boolean;
|
||||||
headLinkId?: string;
|
headLinkId?: string;
|
||||||
headLinkOffset?: number;
|
headLinkOffset?: number;
|
||||||
tailLinkId?: string;
|
tailLinkId?: string;
|
||||||
tailLinkOffset?: number;
|
tailLinkOffset?: number;
|
||||||
occupiedLinkId?: string[];
|
occupiedLinkIndex?: string[];
|
||||||
}): TrainState {
|
}): TrainState {
|
||||||
const message = new TrainState({});
|
const message = new TrainState({});
|
||||||
if (data.id != null) {
|
if (data.id != null) {
|
||||||
message.id = data.id;
|
message.id = data.id;
|
||||||
}
|
}
|
||||||
|
if (data.up != null) {
|
||||||
|
message.up = data.up;
|
||||||
|
}
|
||||||
if (data.headLinkId != null) {
|
if (data.headLinkId != null) {
|
||||||
message.headLinkId = data.headLinkId;
|
message.headLinkId = data.headLinkId;
|
||||||
}
|
}
|
||||||
@ -420,23 +434,27 @@ export namespace state {
|
|||||||
if (data.tailLinkOffset != null) {
|
if (data.tailLinkOffset != null) {
|
||||||
message.tailLinkOffset = data.tailLinkOffset;
|
message.tailLinkOffset = data.tailLinkOffset;
|
||||||
}
|
}
|
||||||
if (data.occupiedLinkId != null) {
|
if (data.occupiedLinkIndex != null) {
|
||||||
message.occupiedLinkId = data.occupiedLinkId;
|
message.occupiedLinkIndex = data.occupiedLinkIndex;
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
toObject() {
|
toObject() {
|
||||||
const data: {
|
const data: {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
up?: boolean;
|
||||||
headLinkId?: string;
|
headLinkId?: string;
|
||||||
headLinkOffset?: number;
|
headLinkOffset?: number;
|
||||||
tailLinkId?: string;
|
tailLinkId?: string;
|
||||||
tailLinkOffset?: number;
|
tailLinkOffset?: number;
|
||||||
occupiedLinkId?: string[];
|
occupiedLinkIndex?: string[];
|
||||||
} = {};
|
} = {};
|
||||||
if (this.id != null) {
|
if (this.id != null) {
|
||||||
data.id = this.id;
|
data.id = this.id;
|
||||||
}
|
}
|
||||||
|
if (this.up != null) {
|
||||||
|
data.up = this.up;
|
||||||
|
}
|
||||||
if (this.headLinkId != null) {
|
if (this.headLinkId != null) {
|
||||||
data.headLinkId = this.headLinkId;
|
data.headLinkId = this.headLinkId;
|
||||||
}
|
}
|
||||||
@ -449,8 +467,8 @@ export namespace state {
|
|||||||
if (this.tailLinkOffset != null) {
|
if (this.tailLinkOffset != null) {
|
||||||
data.tailLinkOffset = this.tailLinkOffset;
|
data.tailLinkOffset = this.tailLinkOffset;
|
||||||
}
|
}
|
||||||
if (this.occupiedLinkId != null) {
|
if (this.occupiedLinkIndex != null) {
|
||||||
data.occupiedLinkId = this.occupiedLinkId;
|
data.occupiedLinkIndex = this.occupiedLinkIndex;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -460,16 +478,18 @@ export namespace state {
|
|||||||
const writer = w || new pb_1.BinaryWriter();
|
const writer = w || new pb_1.BinaryWriter();
|
||||||
if (this.id.length)
|
if (this.id.length)
|
||||||
writer.writeString(1, this.id);
|
writer.writeString(1, this.id);
|
||||||
|
if (this.up != false)
|
||||||
|
writer.writeBool(2, this.up);
|
||||||
if (this.headLinkId.length)
|
if (this.headLinkId.length)
|
||||||
writer.writeString(2, this.headLinkId);
|
writer.writeString(3, this.headLinkId);
|
||||||
if (this.headLinkOffset != 0)
|
if (this.headLinkOffset != 0)
|
||||||
writer.writeInt64(3, this.headLinkOffset);
|
writer.writeInt64(4, this.headLinkOffset);
|
||||||
if (this.tailLinkId.length)
|
if (this.tailLinkId.length)
|
||||||
writer.writeString(4, this.tailLinkId);
|
writer.writeString(5, this.tailLinkId);
|
||||||
if (this.tailLinkOffset != 0)
|
if (this.tailLinkOffset != 0)
|
||||||
writer.writeInt64(5, this.tailLinkOffset);
|
writer.writeInt64(6, this.tailLinkOffset);
|
||||||
if (this.occupiedLinkId.length)
|
if (this.occupiedLinkIndex.length)
|
||||||
writer.writeRepeatedString(6, this.occupiedLinkId);
|
writer.writeRepeatedString(7, this.occupiedLinkIndex);
|
||||||
if (!w)
|
if (!w)
|
||||||
return writer.getResultBuffer();
|
return writer.getResultBuffer();
|
||||||
}
|
}
|
||||||
@ -483,19 +503,22 @@ export namespace state {
|
|||||||
message.id = reader.readString();
|
message.id = reader.readString();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
message.headLinkId = reader.readString();
|
message.up = reader.readBool();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
message.headLinkOffset = reader.readInt64();
|
message.headLinkId = reader.readString();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
message.tailLinkId = reader.readString();
|
message.headLinkOffset = reader.readInt64();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
message.tailLinkOffset = reader.readInt64();
|
message.tailLinkId = reader.readString();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
pb_1.Message.addToRepeatedField(message, 6, reader.readString());
|
message.tailLinkOffset = reader.readInt64();
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
pb_1.Message.addToRepeatedField(message, 7, reader.readString());
|
||||||
break;
|
break;
|
||||||
default: reader.skipField();
|
default: reader.skipField();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ export const useLineStore = defineStore('line', {
|
|||||||
selectedGraphics: null as JlGraphic[] | null,
|
selectedGraphics: null as JlGraphic[] | null,
|
||||||
lineId: null as number | null,
|
lineId: null as number | null,
|
||||||
lineName: null as string | null,
|
lineName: null as string | null,
|
||||||
|
simulationId: null as string | null,
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
selectedGraphicType: (state) => {
|
selectedGraphicType: (state) => {
|
||||||
@ -46,5 +47,8 @@ export const useLineStore = defineStore('line', {
|
|||||||
setLineName(name: string | null) {
|
setLineName(name: string | null) {
|
||||||
this.lineName = name;
|
this.lineName = name;
|
||||||
},
|
},
|
||||||
|
setSimulationId(id: string | null) {
|
||||||
|
this.simulationId = id;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user