列车调整

This commit is contained in:
dong 2023-07-06 16:43:21 +08:00
parent 0a2d5af597
commit 141d351794
5 changed files with 199 additions and 75 deletions

80
src/api/TrainApi.ts Normal file
View File

@ -0,0 +1,80 @@
import { api } from 'src/boot/axios';
const PublishUriBase = '/mock/train';
export interface Mode {
ipModeTrainTypeManual: boolean;
ipModeTrainTypeHead: boolean;
ipModeTrainTypeSpecial: boolean;
ipModeTrainTypeSchedule: boolean;
ipModeTrainSchdEarly: boolean;
ipModeTrainSchdLate: boolean;
ipModeTrainSkipstop: boolean;
ipModeTrainCbtcMode: boolean;
ipModeTrainAtpCut: boolean;
ipModeTrainBerthed: boolean;
ipModeTrainHolded: boolean;
ipModeTrainDirUp: boolean;
ipModeTrainDirDown: boolean;
ipModeTrainDirHeadUp: boolean;
ipModeTrainDirHeadDown: boolean;
ipModeTrainDoorOpen: boolean;
ipModeTrainEbAlarm: boolean;
ipModeTrainIntegrityAlarm: boolean;
ipModeTrainDriveModeAm: boolean;
ipModeTrainDriveModeCm: boolean;
ipModeTrainDriveModeRmf: boolean;
ipModeTrainDriveModeAtb: boolean;
ipModeTrainDriveBlockAm: boolean;
ipModeTrainDriveBlockCm: boolean;
ipModeTrainDriveModeRmr: boolean;
}
export enum DevType {
DEVICE_TYPE_UNKNOW = 'DEVICE_TYPE_UNKNOW',
DEVICE_TYPE_RTU = 'DEVICE_TYPE_RTU',
DEVICE_TYPE_STATION = 'DEVICE_TYPE_STATION',
DEVICE_TYPE_SIGNAL = 'DEVICE_TYPE_SIGNAL',
DEVICE_TYPE_SWITCH = 'DEVICE_TYPE_SWITCH',
DEVICE_TYPE_TRACK = 'DEVICE_TYPE_TRACK',
DEVICE_TYPE_ENTRY = 'DEVICE_TYPE_ENTRY',
DEVICE_TYPE_PLATFORM = 'DEVICE_TYPE_PLATFORM',
DEVICE_TYPE_SCADA = 'DEVICE_TYPE_SCADA',
DEVICE_TYPE_WATERPROOF_DOOR = 'DEVICE_TYPE_WATERPROOF_DOOR',
DEVICE_TYPE_WORK_AREA = 'DEVICE_TYPE_WORK_AREA',
DEVICE_TYPE_GAMA = 'DEVICE_TYPE_GAMA',
}
export function trainMockApi(
lineId: number,
data: {
groupId: string;
window: {
nccWindow: number;
nccWinOffset: number;
};
mode: Mode;
devType: DevType;
devName: string;
type: boolean;
}
) {
return api.post(`${PublishUriBase}/offset/${lineId}`, data);
}
export function removeTrainMockApi(
lineId: number,
data: {
lineId: number;
rtuId: number;
window: {
nccWindow: number;
nccWinOffset: number;
};
deviceType: string;
devName: string;
trainIndex: string;
groupId: string;
}
) {
return api.post(`${PublishUriBase}/remove/${lineId}`, data);
}

View File

@ -12,6 +12,8 @@ import {
JlGraphic, JlGraphic,
} from 'src/jl-graphic'; } from 'src/jl-graphic';
import { DisplayObject, FederatedMouseEvent } from 'pixi.js'; import { DisplayObject, FederatedMouseEvent } from 'pixi.js';
import { DevType, removeTrainMockApi } from 'src/api/TrainApi';
import { useLineStore } from 'src/stores/line-store';
export class TrainData extends GraphicDataBase implements ITrainData { export class TrainData extends GraphicDataBase implements ITrainData {
constructor(data?: graphicData.Train) { constructor(data?: graphicData.Train) {
@ -58,7 +60,7 @@ export class TrainState extends GraphicStateBase implements ITrainState {
} }
get code(): string { get code(): string {
return this.states.trainIndex; return this.states.groupId;
} }
get states(): train.TrainInfo { get states(): train.TrainInfo {
@ -78,13 +80,10 @@ export class TrainState extends GraphicStateBase implements ITrainState {
this.states.rtuId = v; this.states.rtuId = v;
} }
get window(): train.NccWindow { get window(): train.NccWindow {
if (!this.states.window) {
this.states.window = new train.NccWindow();
}
return this.states.window; return this.states.window;
} }
set window(v: train.NccWindow) { set window(v: train.NccWindow) {
this.states.window = v; this.states.window = new train.NccWindow(v);
} }
get devType(): number { get devType(): number {
return this.states.devType; return this.states.devType;
@ -98,10 +97,10 @@ export class TrainState extends GraphicStateBase implements ITrainState {
set devName(v: string) { set devName(v: string) {
this.states.devName = v; this.states.devName = v;
} }
get id(): string { get trainIndex(): string {
return this.states.trainIndex; return this.states.trainIndex;
} }
set id(v: string) { set trainIndex(v: string) {
this.states.trainIndex = v; this.states.trainIndex = v;
} }
get groupId(): string { get groupId(): string {
@ -147,13 +146,10 @@ export class TrainState extends GraphicStateBase implements ITrainState {
this.states.otpTime = v; this.states.otpTime = v;
} }
get mode(): state.TrainMode { get mode(): state.TrainMode {
if (!this.states.mode) {
this.states.mode = new state.TrainMode();
}
return this.states.mode; return this.states.mode;
} }
set mode(v: state.TrainMode) { set mode(v: state.TrainMode) {
this.states.mode = v; this.states.mode = new state.TrainMode(v);
} }
get arriveTime(): number { get arriveTime(): number {
return this.states.arriveTime; return this.states.arriveTime;
@ -195,19 +191,19 @@ export class TrainState extends GraphicStateBase implements ITrainState {
return this.states.remove; return this.states.remove;
} }
set remove(v: train.TrainRemove) { set remove(v: train.TrainRemove) {
this.states.remove = v; this.states.remove = new train.TrainRemove(v);
} }
get block(): train.TrainBlock { get block(): train.TrainBlock {
return this.states.block; return this.states.block;
} }
set block(v: train.TrainBlock) { set block(v: train.TrainBlock) {
this.states.block = v; this.states.block = new train.TrainBlock(v);
} }
get record(): train.TrainRecord { get record(): train.TrainRecord {
return this.states.record; return this.states.record;
} }
set record(v: train.TrainRecord) { set record(v: train.TrainRecord) {
this.states.record = v; this.states.record = new train.TrainRecord(v);
} }
clone(): TrainState { clone(): TrainState {
@ -239,17 +235,21 @@ const openDoorConfig: MenuItemOptions = {
const editGroupConfig: MenuItemOptions = { const editGroupConfig: MenuItemOptions = {
name: '修改车组号', name: '修改车组号',
}; };
const removeTrainConfig: MenuItemOptions = {
name: '删除列车',
};
const TrainOperateMenu: ContextMenu = ContextMenu.init({ const TrainOperateMenu: ContextMenu = ContextMenu.init({
name: '列车操作菜单', name: '列车操作菜单',
groups: [ groups: [
{ {
items: [ items: [
negativeDirectionConfig, // negativeDirectionConfig,
runStopConfig, // runStopConfig,
diriveModelConfig, // diriveModelConfig,
HoldTrainConfig, // HoldTrainConfig,
openDoorConfig, // openDoorConfig,
editGroupConfig, // editGroupConfig,
removeTrainConfig,
], ],
}, },
], ],
@ -268,49 +268,49 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin<Train> {
return grahpics.filter((g) => g.type === Train.Type).map((g) => g as Train); return grahpics.filter((g) => g.type === Train.Type).map((g) => g as Train);
} }
bind(g: Train): void { bind(g: Train): void {
g.eventMode = 'static'; g.trainbody.eventMode = 'static';
g.cursor = 'pointer'; g.trainbody.cursor = 'pointer';
g.selectable = true; g.trainbody.selectable = true;
g.on('_rightclick', this.onContextMenu, this); g.on('_rightclick', this.onContextMenu, this);
} }
unbind(g: Train): void { unbind(g: Train): void {
g.selectable = false; g.trainbody.eventMode = 'none';
g.eventMode = 'none'; g.trainbody.selectable = false;
g.off('_rightclick', this.onContextMenu, this); g.off('_rightclick', this.onContextMenu, this);
} }
onContextMenu(e: FederatedMouseEvent) { onContextMenu(e: FederatedMouseEvent) {
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); const lineStore = useLineStore();
const lineId = lineStore.lineId;
negativeDirectionConfig.handler = () => { negativeDirectionConfig.handler = () => {
const mode = train.states.mode; const mode = train.states.mode;
if (!train.states.mode.ipModeTrainDirUp) { if (!mode.ipModeTrainDirUp) {
mode.ipModeTrainDirUp = true; mode.ipModeTrainDirUp = true;
mode.ipModeTrainDirDown = false; mode.ipModeTrainDirDown = false;
} else if (!train.states.mode.ipModeTrainDirDown) { } else if (!mode.ipModeTrainDirDown) {
mode.ipModeTrainDirUp = false; mode.ipModeTrainDirUp = false;
mode.ipModeTrainDirDown = true; mode.ipModeTrainDirDown = true;
} }
train.doRepaint(); train.doRepaint();
}; };
runStopConfig.handler = () => { runStopConfig.handler = () => {
train.states.mode.ipModeTrainStoped = train.states.mode.ipModeTrainBerthed =
!train.states.mode.ipModeTrainStoped; !train.states.mode.ipModeTrainBerthed;
train.doRepaint(); train.doRepaint();
}; };
diriveModelConfig.handler = () => { diriveModelConfig.handler = () => {
const arr = [ const arr = [
'ipModeTrainDriveModeAm', 'ipModeTrainDriveModeAm',
'ipModeTrainDriveModeCm', 'ipModeTrainDriveModeCm',
'ipModeTrainDriveBlockAm', 'ipModeTrainDriveModeRmf',
'ipModeTrainDriveBlockCm',
]; ];
let findIndex = arr.findIndex((key) => { let findIndex = arr.findIndex((key) => {
return train.states.mode[key]; return train.states.mode[key];
}); });
if (findIndex == 3) { if (findIndex == 2) {
findIndex = -1; findIndex = -1;
} }
arr.forEach((key) => { arr.forEach((key) => {
@ -334,6 +334,30 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin<Train> {
train.states.globalId = '3333'; train.states.globalId = '3333';
train.doRepaint(); train.doRepaint();
}; };
removeTrainConfig.handler = () => {
const params = {
lineId: train.states.lineId,
rtuId: train.states.rtuId,
window: {
nccWindow: train.states.window.nccWindow,
nccWinOffset: train.states.window.nccWindow,
},
deviceType: 'DEVICE_TYPE_TRACK',
devName: train.states.devName,
trainIndex: train.states.trainIndex,
groupId: train.states.groupId,
};
if (lineId) {
removeTrainMockApi(lineId, params)
.then((res) => {
this.app.deleteGraphics(train);
console.log(res, '---res--');
})
.catch((err) => {
console.log(err, '---err---');
});
}
};
TrainOperateMenu.open(e.global); TrainOperateMenu.open(e.global);
} }
} }

View File

@ -4,9 +4,14 @@ import {
StompCli, StompCli,
AppWsMsgBroker, AppWsMsgBroker,
GraphicState, GraphicState,
GraphicIdGenerator,
} from 'src/jl-graphic'; } from 'src/jl-graphic';
import { TrainData, TrainState } from './graphics/TrainInteraction'; import {
import { TrainTemplate } from 'src/graphics/train/Train'; TrainData,
TrainOperateInteraction,
TrainState,
} from './graphics/TrainInteraction';
import { Train, TrainTemplate } from 'src/graphics/train/Train';
import { import {
SignalData, SignalData,
SignalOperateInteraction, SignalOperateInteraction,
@ -48,7 +53,6 @@ import {
import { TrainWindowData } from './graphics/TrainWindowInteraction'; import { TrainWindowData } from './graphics/TrainWindowInteraction';
import { SeparatorTemplate } from 'src/graphics/separator/Separator'; import { SeparatorTemplate } from 'src/graphics/separator/Separator';
import { SeparatorData } from './graphics/SeparatorInteraction'; import { SeparatorData } from './graphics/SeparatorInteraction';
import { train } from 'src/protos/train';
let lineApp: GraphicApp | null = null; let lineApp: GraphicApp | null = null;
let msgBroker: AppWsMsgBroker | null = null; let msgBroker: AppWsMsgBroker | null = null;
@ -92,12 +96,14 @@ export function initLineApp(dom: HTMLElement): GraphicApp {
Signal.Type, Signal.Type,
Platform.Type, Platform.Type,
Station.Type, Station.Type,
Train.Type,
], ],
}, },
}); });
SignalOperateInteraction.init(lineApp); SignalOperateInteraction.init(lineApp);
PlatformOperateInteraction.init(lineApp); PlatformOperateInteraction.init(lineApp);
StationOperateInteraction.init(lineApp); StationOperateInteraction.init(lineApp);
TrainOperateInteraction.init(lineApp);
return lineApp; return lineApp;
} }

View File

@ -19,7 +19,7 @@ export enum separatorTypeEnum {
} }
export const SeparatorConsts = { export const SeparatorConsts = {
height: 15, height: 12,
lineWidth: 2, lineWidth: 2,
lineColor: '0x617799', lineColor: '0x617799',
circleColor: '0xEF0200', circleColor: '0xEF0200',

View File

@ -1,6 +1,7 @@
import { Color, Graphics, Container, Point } from 'pixi.js'; import { Graphics, Container, Point } from 'pixi.js';
import { import {
GraphicData, GraphicData,
GraphicIdGenerator,
GraphicState, GraphicState,
JlGraphic, JlGraphic,
JlGraphicTemplate, JlGraphicTemplate,
@ -9,6 +10,7 @@ import {
} from 'src/jl-graphic'; } from 'src/jl-graphic';
import { train } from 'src/protos/train'; import { train } from 'src/protos/train';
import { state } from 'src/protos/device_status'; import { state } from 'src/protos/device_status';
import { TrainWindow } from '../trainWindow/TrainWindow';
export interface ITrainData extends GraphicData { export interface ITrainData extends GraphicData {
get code(): string; // 车号 get code(): string; // 车号
@ -29,8 +31,8 @@ export interface ITrainState extends GraphicState {
set devType(v: state.DeviceType); set devType(v: state.DeviceType);
get devName(): string; // 所在设备名称 get devName(): string; // 所在设备名称
set devName(v: string); set devName(v: string);
get id(): string; // 设备唯一与trainIndex相同 get trainIndex(): string; // 设备唯一与trainIndex相同
set id(v: string); set trainIndex(v: string);
get groupId(): string; // 列车车组号 get groupId(): string; // 列车车组号
set groupId(v: string); set groupId(v: string);
get trainId(): string; // 列车表号 get trainId(): string; // 列车表号
@ -88,12 +90,10 @@ enum DiriveModelColorEnum { // 驾驶模式对应颜色
NRM = '0xA0522D', // 非限制人工驾驶模式 NRM = '0xA0522D', // 非限制人工驾驶模式
red = '0xF80103', // 红色表示通信中断 red = '0xF80103', // 红色表示通信中断
} }
enum AAColorEnum { // 识别号AA颜色 enum BBBColorEnum { // 识别号颜色
accuracy = '0xffffff', // 准点 accuracy = '0xffffff', // 准点
early = '0x00FF00', // 早点 early = '0x00FF00', // 早点
late = '0xA0522D', // 晚点 late = '0xFFFF00', // 晚点
}
enum typeColorEnum { // 识别号BBB颜色
schedule = '0xffffff', // 计划车 schedule = '0xffffff', // 计划车
head = '0xE9FC01', // 头码车 head = '0xE9FC01', // 头码车
manual = '0xE9FC01', // 人工车 manual = '0xE9FC01', // 人工车
@ -136,10 +136,10 @@ export class TrainHead extends Container {
} }
doRepaint(states: ITrainState, bodyWH?: bodyWH) { doRepaint(states: ITrainState, bodyWH?: bodyWH) {
let direction = ''; let direction = '';
if (states.mode?.ipModeTrainDirUp) { if (states.mode?.ipModeTrainDirDown) {
direction = 'left'; direction = 'left';
} }
if (states.mode?.ipModeTrainDirDown) { if (states.mode?.ipModeTrainDirUp) {
direction = 'right'; direction = 'right';
} }
this.clear(); this.clear();
@ -189,14 +189,14 @@ export class TrainHead extends Container {
if (states.mode?.ipModeTrainDriveModeCm) { if (states.mode?.ipModeTrainDriveModeCm) {
aColor = DiriveModelColorEnum.SM; aColor = DiriveModelColorEnum.SM;
pColor = DiriveModelColorEnum.SM; pColor = DiriveModelColorEnum.SM;
} else if (states.mode?.ipModeTrainDriveBlockAm) { } else if (
states.mode?.ipModeTrainDriveModeRmf ||
states.mode?.ipModeTrainDriveModeRmr
) {
aColor = DiriveModelColorEnum.RM; aColor = DiriveModelColorEnum.RM;
pColor = DiriveModelColorEnum.RM; pColor = DiriveModelColorEnum.RM;
} else if (states.mode?.ipModeTrainDriveBlockCm) {
aColor = DiriveModelColorEnum.NRM;
pColor = DiriveModelColorEnum.NRM;
} }
if (states.mode?.ipModeTrainStoped) { if (states.mode?.ipModeTrainBerthed) {
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]);
@ -210,27 +210,27 @@ export class TrainHead extends Container {
} }
export class TrainBody extends Container { export class TrainBody extends Container {
codeRact: Graphics; // codeRact: Graphics;
codeAGraph: VectorText = new VectorText(''); //识别号AA codeAGraph: VectorText = new VectorText(''); //识别号AA
codeBGraph: VectorText = new VectorText(''); //识别号BBB codeBGraph: VectorText = new VectorText(''); //识别号BBB
constructor() { constructor() {
super(); super();
this.codeRact = new Graphics(); // this.codeRact = new Graphics();
this.addChild(this.codeRact); // this.addChild(this.codeRact);
this.addChild(this.codeAGraph); this.addChild(this.codeAGraph);
this.addChild(this.codeBGraph); this.addChild(this.codeBGraph);
this.codeAGraph.setVectorFontSize(trainConsts.codeFontSize); this.codeAGraph.setVectorFontSize(trainConsts.codeFontSize);
this.codeBGraph.setVectorFontSize(trainConsts.codeFontSize); this.codeBGraph.setVectorFontSize(trainConsts.codeFontSize);
} }
clear() { clear() {
this.codeRact.clear(); // this.codeRact.clear();
} }
getBodyWH(): bodyWH { getBodyWH(): bodyWH {
const bodyAWH = this.codeAGraph.getLocalBounds(); const bodyAWH = this.codeAGraph.getLocalBounds();
const bodyBWH = this.codeBGraph.getLocalBounds(); const bodyBWH = this.codeBGraph.getLocalBounds();
return { return {
width: bodyAWH.width + bodyBWH.width + trainConsts.codePadding * 2, width: bodyAWH.width + bodyBWH.width,
height: bodyAWH.height + trainConsts.codePadding * 2, height: bodyAWH.height,
}; };
} }
@ -238,27 +238,28 @@ export class TrainBody extends Container {
this.clear(); this.clear();
const codeAGraph = this.codeAGraph; const codeAGraph = this.codeAGraph;
const codeBGraph = this.codeBGraph; const codeBGraph = this.codeBGraph;
const codeRact = this.codeRact; // const codeRact = this.codeRact;
let codeA = states?.trainId; let codeA = states?.groupId;
let fillAColor = AAColorEnum.accuracy; const fillAColor = BBBColorEnum.schedule;
if (states.mode?.ipModeTrainSchdLate) { let fillBColor = BBBColorEnum.schedule;
fillAColor = AAColorEnum.late; if (states.mode?.ipModeTrainTypeSchedule) {
} else if (states.mode?.ipModeTrainSchdEarly) { if (states.mode?.ipModeTrainSchdLate) {
fillAColor = AAColorEnum.early; fillBColor = BBBColorEnum.late;
} } else if (states.mode?.ipModeTrainSchdEarly) {
let fillBColor = typeColorEnum.schedule; fillBColor = BBBColorEnum.early;
if (states.mode?.ipModeTrainTypeHead) { }
} else if (states.mode?.ipModeTrainTypeHead) {
codeA = states?.destinationId + ''; codeA = states?.destinationId + '';
fillBColor = typeColorEnum.head; fillBColor = BBBColorEnum.head;
} else if (states.mode?.ipModeTrainTypeManual) { } else if (states.mode?.ipModeTrainTypeManual) {
codeA = 'MM'; codeA = 'MM';
fillBColor = typeColorEnum.manual; fillBColor = BBBColorEnum.manual;
} else if (states.mode?.ipModeTrainTypeSpecial) { } else if (states.mode?.ipModeTrainTypeSpecial) {
codeA = ''; codeA = '';
} }
const codeB = states?.globalId; const codeB = states?.globalId;
codeAGraph.text = codeA || '01'; codeAGraph.text = codeA || '01';
codeBGraph.text = codeB || '2222'; codeBGraph.text = codeB || '222';
codeAGraph.anchor.set(0.5); codeAGraph.anchor.set(0.5);
codeBGraph.anchor.set(0.5); codeBGraph.anchor.set(0.5);
const styleA = { const styleA = {
@ -277,10 +278,10 @@ export class TrainBody extends Container {
codeBGraph.position.set(bodyAWH.width / 2, 0); codeBGraph.position.set(bodyAWH.width / 2, 0);
codeAGraph.updateOnScaled(); codeAGraph.updateOnScaled();
codeBGraph.updateOnScaled(); codeBGraph.updateOnScaled();
const { width: codeWidth, height: codeHeight } = this.getBodyWH(); // const { width: codeWidth, height: codeHeight } = this.getBodyWH();
codeRact.beginFill(new Color(TrainColorEnum.bodyColor)); // codeRact.beginFill(new Color(TrainColorEnum.bodyColor));
codeRact.drawRect(-codeWidth / 2, -codeHeight / 2, codeWidth, codeHeight); // codeRact.drawRect(-codeWidth / 2, -codeHeight / 2, codeWidth, codeHeight);
codeRact.endFill(); // codeRact.endFill();
} }
} }
@ -342,6 +343,10 @@ export class Train extends JlGraphic {
return this.getStates<ITrainState>(); return this.getStates<ITrainState>();
} }
get code(): string {
return this.states.code;
}
doRepaint(): void { doRepaint(): void {
this.trainbody.doRepaint(this.states); this.trainbody.doRepaint(this.states);
const bodyWH = this.trainbody.getBodyWH(); const bodyWH = this.trainbody.getBodyWH();
@ -366,6 +371,7 @@ export class Train extends JlGraphic {
} else { } else {
this.hideStatus('A'); this.hideStatus('A');
} }
this.setPosition();
} }
showStatus(s: string) { showStatus(s: string) {
@ -388,6 +394,14 @@ export class Train extends JlGraphic {
this.statusTextMap.delete(s); this.statusTextMap.delete(s);
} }
} }
setPosition(): void {
const wId = this.states.window?.nccWindow;
if (wId) {
const window = this.queryStore.queryById<TrainWindow>(wId + '');
const p = window.getPositionOnCanvas();
this.position.set(p.x, p.y);
}
}
} }
export class TrainTemplate extends JlGraphicTemplate<Train> { export class TrainTemplate extends JlGraphicTemplate<Train> {
@ -396,7 +410,7 @@ export class TrainTemplate extends JlGraphicTemplate<Train> {
} }
new(): Train { new(): Train {
const train = new Train(); const train = new Train();
train.loadData(this.datas); train.id = GraphicIdGenerator.next();
train.loadState(this.states); train.loadState(this.states);
return train; return train;
} }