道岔定反位设置
This commit is contained in:
parent
72266db5ea
commit
6c3356450c
@ -49,6 +49,15 @@ export async function removeTrain(data: {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function setSwitchPosition(data: {
|
||||
simulationId: string;
|
||||
switchIndex: number;
|
||||
turnNormal: boolean;
|
||||
turnReverse: boolean;
|
||||
}) {
|
||||
return await api.post(`${UriBase}/switch/operation`, data);
|
||||
}
|
||||
|
||||
export function checkMapData(data: { mapProto: string }) {
|
||||
return api.post(`${UriBase}/check/data`, data);
|
||||
}
|
||||
|
@ -4,16 +4,16 @@ function getHost(): string {
|
||||
// return '192.168.3.37:9091';
|
||||
// return '192.168.3.15:9091';
|
||||
// return '192.168.3.5:9091';
|
||||
// return '192.168.3.233:9091';
|
||||
return 'test.joylink.club/bjrtss-server';
|
||||
return '192.168.3.233:9091';
|
||||
// return 'test.joylink.club/bjrtss-server';
|
||||
}
|
||||
|
||||
export function getHttpBase() {
|
||||
// return `http://${getHost()}`;
|
||||
return `https://${getHost()}`;
|
||||
return `http://${getHost()}`;
|
||||
// return `https://${getHost()}`;
|
||||
}
|
||||
|
||||
export function getWebsocketUrl() {
|
||||
// return `ws://${getHost()}/ws-bj`;
|
||||
return `wss://${getHost()}/ws-bj`;
|
||||
return `ws://${getHost()}/ws-bj`;
|
||||
// return `wss://${getHost()}/ws-bj`;
|
||||
}
|
||||
|
@ -6,9 +6,22 @@ import {
|
||||
import * as pb_1 from 'google-protobuf';
|
||||
import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase';
|
||||
import { graphicData } from 'src/protos/stationLayoutGraphics';
|
||||
import { IPointData } from 'pixi.js';
|
||||
import { DisplayObject, FederatedMouseEvent, IPointData } from 'pixi.js';
|
||||
import { KilometerSystem } from 'src/graphics/signal/Signal';
|
||||
import { state } from 'src/protos/device_state';
|
||||
import {
|
||||
GraphicApp,
|
||||
GraphicInteractionPlugin,
|
||||
JlGraphic,
|
||||
} from 'src/jl-graphic';
|
||||
import {
|
||||
ForkHitArea,
|
||||
TurnoutSectionHitArea,
|
||||
} from 'src/graphics/turnout/TurnoutDrawAssistant';
|
||||
import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
|
||||
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
|
||||
import { useLineStore } from 'src/stores/line-store';
|
||||
import { setSwitchPosition } from 'src/api/Simulation';
|
||||
|
||||
function getDefaultEndPoint() {
|
||||
return {
|
||||
@ -18,6 +31,68 @@ function getDefaultEndPoint() {
|
||||
};
|
||||
}
|
||||
|
||||
const setNormalPosition: MenuItemOptions = { name: '设置定位' };
|
||||
const setReversePosition: MenuItemOptions = { name: '设置反位' };
|
||||
|
||||
const TurnoutOperationMenu: ContextMenu = ContextMenu.init({
|
||||
name: 'Turnout操作',
|
||||
groups: [{ items: [setNormalPosition, setReversePosition] }],
|
||||
});
|
||||
|
||||
export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> {
|
||||
static Name = 'turnout_operate_menu';
|
||||
constructor(app: GraphicApp) {
|
||||
super(TurnoutOperationPlugin.Name, app);
|
||||
app.registerMenu(TurnoutOperationMenu);
|
||||
}
|
||||
static init(app: GraphicApp) {
|
||||
return new TurnoutOperationPlugin(app);
|
||||
}
|
||||
filter(...grahpics: JlGraphic[]): Turnout[] | undefined {
|
||||
return grahpics.filter<Turnout>((g): g is Turnout => g instanceof Turnout);
|
||||
}
|
||||
bind(g: Turnout): void {
|
||||
g.graphics.fork.eventMode = 'static';
|
||||
g.graphics.fork.cursor = 'pointer';
|
||||
g.graphics.fork.hitArea = new ForkHitArea(g);
|
||||
g.graphics.sections.forEach((sectionGraphic) => {
|
||||
sectionGraphic.eventMode = 'static';
|
||||
sectionGraphic.cursor = 'pointer';
|
||||
sectionGraphic.hitArea = new TurnoutSectionHitArea(sectionGraphic);
|
||||
});
|
||||
g.on('rightclick', this.onContextMenu, this);
|
||||
}
|
||||
unbind(g: Turnout): void {
|
||||
g.graphics.fork.eventMode = 'none';
|
||||
g.graphics.sections.forEach((sectionGraphic) => {
|
||||
sectionGraphic.eventMode = 'none';
|
||||
});
|
||||
g.off('rightclick', this.onContextMenu);
|
||||
}
|
||||
onContextMenu(e: FederatedMouseEvent) {
|
||||
const target = e.target as DisplayObject;
|
||||
const turnout = target.getGraphic<Turnout>();
|
||||
if (!turnout) return;
|
||||
this.app.updateSelected(turnout);
|
||||
const simulationId = useLineStore().simulationId || '';
|
||||
const setPosition = async (normal: boolean) => {
|
||||
setSwitchPosition({
|
||||
simulationId,
|
||||
switchIndex: turnout.datas.index,
|
||||
turnNormal: normal,
|
||||
turnReverse: !normal,
|
||||
});
|
||||
};
|
||||
setNormalPosition.handler = async () => {
|
||||
await setPosition(true);
|
||||
};
|
||||
setReversePosition.handler = async () => {
|
||||
await setPosition(false);
|
||||
};
|
||||
TurnoutOperationMenu.open(e.global);
|
||||
}
|
||||
}
|
||||
|
||||
export class TurnoutData extends GraphicDataBase implements ITurnoutData {
|
||||
constructor(data?: graphicData.Turnout) {
|
||||
let turnout = new graphicData.Turnout();
|
||||
|
@ -26,7 +26,11 @@ import {
|
||||
StationState,
|
||||
} from './graphics/StationInteraction';
|
||||
import { Station, StationTemplate } from 'src/graphics/station/Station';
|
||||
import { TurnoutData, TurnoutStates } from './graphics/TurnoutInteraction';
|
||||
import {
|
||||
TurnoutData,
|
||||
TurnoutOperationPlugin,
|
||||
TurnoutStates,
|
||||
} from './graphics/TurnoutInteraction';
|
||||
import { Turnout, TurnoutTemplate } from 'src/graphics/turnout/Turnout';
|
||||
import { SectionData } from './graphics/SectionInteraction';
|
||||
import { Section, SectionTemplate } from 'src/graphics/section/Section';
|
||||
@ -144,6 +148,7 @@ export function initLineApp(dom: HTMLElement): GraphicApp {
|
||||
Station.Type,
|
||||
SectionLink.Type,
|
||||
Train.Type,
|
||||
Turnout.Type,
|
||||
],
|
||||
},
|
||||
});
|
||||
@ -152,6 +157,7 @@ export function initLineApp(dom: HTMLElement): GraphicApp {
|
||||
StationOperateInteraction.init(lineApp);
|
||||
SectionLinkOperateInteraction.init(lineApp);
|
||||
TrainOperateInteraction.init(lineApp);
|
||||
TurnoutOperationPlugin.init(lineApp);
|
||||
// 画布右键菜单
|
||||
lineApp.registerMenu(DefaultCanvasMenu);
|
||||
lineApp.canvas.on('_rightclick', (e) => {
|
||||
@ -254,7 +260,7 @@ export async function loadLineDatas(app: GraphicApp) {
|
||||
messageConverter: (message: Uint8Array) => {
|
||||
const states: GraphicState[] = [];
|
||||
const storage = state.PushedDevicesStatus.deserialize(message);
|
||||
console.log(storage, 'storage');
|
||||
// console.log(storage, 'storage');
|
||||
if (storage.all) {
|
||||
storage.allStatus.sectionState.forEach((item) => {
|
||||
if (state.SectionType[item.type] == 'Axle') {
|
||||
|
@ -100,7 +100,6 @@ export class rectGraphic extends Container {
|
||||
this.addChild(this.rectGraphic);
|
||||
}
|
||||
draw(state: IPlatformState): void {
|
||||
console.info(state);
|
||||
const rectGraphic = this.rectGraphic;
|
||||
rectGraphic.clear();
|
||||
const fillColor = PlatformColorEnum.white;
|
||||
@ -139,7 +138,6 @@ export class doorGraphic extends Container {
|
||||
this.addChild(this.doorCloseGraphic);
|
||||
}
|
||||
draw(stateData: IPlatformState): void {
|
||||
console.info(stateData);
|
||||
const doorGraphic = this.doorGraphic;
|
||||
const doorCloseGraphic = this.doorCloseGraphic;
|
||||
doorGraphic.clear();
|
||||
|
@ -177,7 +177,7 @@ export class Turnout extends JlGraphic {
|
||||
}
|
||||
|
||||
doRepaint(): void {
|
||||
console.log(this.states);
|
||||
// console.log(this.states);
|
||||
const { pointB, pointC } = this.datas;
|
||||
if (this.states.normal) {
|
||||
this.graphics.fork.paint(pointB[0]);
|
||||
|
@ -69,34 +69,7 @@ export class TurnoutDraw extends GraphicDrawAssistant<
|
||||
}
|
||||
}
|
||||
|
||||
export class TurnoutHitArea implements IHitArea {
|
||||
turnout: Turnout;
|
||||
constructor(turnout: Turnout) {
|
||||
this.turnout = turnout;
|
||||
}
|
||||
contains(x: number, y: number): boolean {
|
||||
const { pointA, pointB, pointC } = this.turnout.datas;
|
||||
return (
|
||||
polylinePoint(
|
||||
[...pointA, { x: 0, y: 0 }],
|
||||
{ x, y },
|
||||
TurnoutConsts.lineWidth
|
||||
) ||
|
||||
polylinePoint(
|
||||
[...pointB, { x: 0, y: 0 }],
|
||||
{ x, y },
|
||||
TurnoutConsts.lineWidth
|
||||
) ||
|
||||
polylinePoint(
|
||||
[...pointC, { x: 0, y: 0 }],
|
||||
{ x, y },
|
||||
TurnoutConsts.lineWidth
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ForkHitArea implements IHitArea {
|
||||
export class ForkHitArea implements IHitArea {
|
||||
turnout: Turnout;
|
||||
constructor(turnout: Turnout) {
|
||||
this.turnout = turnout;
|
||||
@ -128,7 +101,7 @@ class ForkHitArea implements IHitArea {
|
||||
}
|
||||
}
|
||||
|
||||
class TurnoutSectionHitArea implements IHitArea {
|
||||
export class TurnoutSectionHitArea implements IHitArea {
|
||||
section: TurnoutSection;
|
||||
constructor(section: TurnoutSection) {
|
||||
this.section = section;
|
||||
|
Loading…
Reference in New Issue
Block a user