This commit is contained in:
fan 2023-10-12 13:23:09 +08:00
commit 4939a196e4
12 changed files with 127 additions and 431 deletions

View File

@ -61,6 +61,8 @@ const tableRef = ref<QTable>();
const deviceTypeMap = { const deviceTypeMap = {
1: '道岔', 1: '道岔',
5: '信号机', 5: '信号机',
6: '车站',
7: '屏蔽门',
}; };
const columns: QTable['columns'] = [ const columns: QTable['columns'] = [
{ {

View File

@ -17,14 +17,6 @@
@blur="onUpdate" @blur="onUpdate"
label="索引" label="索引"
/> />
<q-input
v-if="platformModel.hasdoor"
outlined
v-model.number="platformModel.sonDoorAmount"
type="number"
@blur="onUpdate"
label="子屏蔽门的数量"
/>
<q-list bordered separator class="rounded-borders"> <q-list bordered separator class="rounded-borders">
<q-item> <q-item>
<q-item-section no-wrap class="q-gutter-y-sm column"> <q-item-section no-wrap class="q-gutter-y-sm column">
@ -36,6 +28,16 @@
</div> </div>
</q-item-section> </q-item-section>
</q-item> </q-item>
<q-item>
<q-item-section no-wrap class="q-gutter-y-sm column">
<q-item-label> 关联的物理区段 </q-item-label>
<div class="q-gutter-sm row">
<q-chip square color="primary" text-color="white">
{{ sectionRelation }}
</q-chip>
</div>
</q-item-section>
</q-item>
</q-list> </q-list>
</q-form> </q-form>
</template> </template>
@ -47,6 +49,7 @@ import { useDrawStore } from 'src/stores/draw-store';
import { computed } from 'vue'; import { computed } from 'vue';
import { Station } from 'src/graphics/station/Station'; import { Station } from 'src/graphics/station/Station';
import { Platform } from 'src/graphics/platform/Platform'; import { Platform } from 'src/graphics/platform/Platform';
import { Section } from 'src/graphics/section/Section';
const drawStore = useDrawStore(); const drawStore = useDrawStore();
const { data: platformModel, onUpdate } = useFormData( const { data: platformModel, onUpdate } = useFormData(
@ -61,7 +64,18 @@ const stationRelation = computed(() => {
.map((relation) => relation.getOtherGraphic<Station>(platform).datas.code); .map((relation) => relation.getOtherGraphic<Station>(platform).datas.code);
let refStation; let refStation;
if (refStations) { if (refStations) {
return (refStation = refStations[0]); refStation = refStations[0];
}
return refStation;
});
const sectionRelation = computed(() => {
const platform = drawStore.selectedGraphic as Platform;
const refSections = platform?.relationManage
.getRelationsOfGraphicAndOtherType(platform, Section.Type)
.map((relation) => relation.getOtherGraphic<Section>(platform).datas.code);
let refStation;
if (refSections) {
refStation = refSections[0];
} }
return refStation; return refStation;
}); });

View File

@ -131,6 +131,8 @@ const handleState = ref('新建设备关联继电器');
const optionsType = [ const optionsType = [
{ label: '道岔', value: graphicData.RelatedRef.DeviceType.Turnout }, { label: '道岔', value: graphicData.RelatedRef.DeviceType.Turnout },
{ label: '信号机', value: graphicData.RelatedRef.DeviceType.signal }, { label: '信号机', value: graphicData.RelatedRef.DeviceType.signal },
{ label: '车站', value: graphicData.RelatedRef.DeviceType.station },
{ label: '屏蔽门', value: graphicData.RelatedRef.DeviceType.ScreenDoor },
]; ];
let selectGraphic: JlGraphic[] = []; let selectGraphic: JlGraphic[] = [];

View File

@ -11,7 +11,6 @@
autogrow autogrow
/> />
<q-input <q-input
v-if="screenDoorModel.hasdoor"
outlined outlined
v-model.number="screenDoorModel.sonDoorAmount" v-model.number="screenDoorModel.sonDoorAmount"
type="number" type="number"
@ -56,7 +55,7 @@ const platformRelation = computed(() => {
); );
let refStation; let refStation;
if (refStations) { if (refStations) {
return (refStation = refStations[0]); refStation = refStations[0];
} }
return refStation; return refStation;
}); });

View File

@ -1,6 +1,6 @@
<template> <template>
<q-form class="q-gutter-sm"> <q-form class="q-gutter-sm">
<q-input outlined readonly v-model="stationModel.id" label="id" hint="" /> <q-input outlined readonly v-model="stationModel.id" label="id" />
<q-input <q-input
outlined outlined
label="车站名称" label="车站名称"

View File

@ -7,8 +7,6 @@ import {
import { graphicData } from 'src/protos/stationLayoutGraphics'; import { graphicData } from 'src/protos/stationLayoutGraphics';
import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase'; import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase';
import { state } from 'src/protos/device_state'; import { state } from 'src/protos/device_state';
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
import { import {
IGraphicScene, IGraphicScene,
GraphicInteractionPlugin, GraphicInteractionPlugin,
@ -46,11 +44,11 @@ export class PlatformData extends GraphicDataBase implements IPlatformData {
set index(v: number) { set index(v: number) {
this.data.index = v; this.data.index = v;
} }
get refStation(): string { get platformRef(): graphicData.RelatedRef[] {
return this.data.refStation; return this.data.platformRef;
} }
set refStation(v: string) { set platformRef(points: graphicData.RelatedRef[]) {
this.data.refStation = v; this.data.platformRef = points;
} }
clone(): PlatformData { clone(): PlatformData {
@ -92,86 +90,10 @@ export class PlatformState extends GraphicStateBase implements IPlatformState {
} }
} }
const holdConfig: MenuItemOptions = {
name: '扣车',
};
const removeHoldrConfig: MenuItemOptions = {
name: '取消扣车',
};
// const batchHoldConfig: MenuItemOptions = {
// name: '批量扣车',
// };
// const removeBatchHoldConfig: MenuItemOptions = {
// name: '批量取消扣车',
// };
// const earlyDepartureConfig: MenuItemOptions = {
// name: '提前发车',
// };
const skipStopConfig: MenuItemOptions = {
name: '设置跳停',
};
const removeSkipStopConfig: MenuItemOptions = {
name: '取消跳停',
};
const dockTimeConfig: MenuItemOptions = {
name: '设置停站时间',
};
const operatingLevelConfig: MenuItemOptions = {
name: '设置运行等级',
};
// const numberOfRegionalTrainsConfig: MenuItemOptions = {
// name: '区间列车数量限制',
// };
// const removeNumberOfRegionalTrainsConfig: MenuItemOptions = {
// name: '取消区间列车数量限制',
// };
// const platformMessadeConfig: MenuItemOptions = {
// name: '站台详细信息',
// };
const PlatformOperateMenu: ContextMenu = ContextMenu.init({
name: '站台操作菜单',
groups: [
{
items: [
holdConfig,
removeHoldrConfig,
skipStopConfig,
removeSkipStopConfig,
dockTimeConfig,
operatingLevelConfig,
],
},
],
});
// const dispatchPlatformOperateMenu: ContextMenu = ContextMenu.init({
// name: '调度仿真站台操作菜单',
// groups: [
// {
// items: [
// holdConfig,
// removeHoldrConfig,
// batchHoldConfig,
// removeBatchHoldConfig,
// earlyDepartureConfig,
// skipStopConfig,
// removeSkipStopConfig,
// dockTimeConfig,
// operatingLevelConfig,
// numberOfRegionalTrainsConfig,
// removeNumberOfRegionalTrainsConfig,
// platformMessadeConfig,
// ],
// },
// ],
// });
export class PlatformOperateInteraction extends GraphicInteractionPlugin<Platform> { export class PlatformOperateInteraction extends GraphicInteractionPlugin<Platform> {
static Name = 'platform_operate_menu'; static Name = 'platform_operate_menu';
constructor(app: IGraphicScene) { constructor(app: IGraphicScene) {
super(PlatformOperateInteraction.Name, app); super(PlatformOperateInteraction.Name, app);
app.registerMenu(PlatformOperateMenu);
} }
static init(app: IGraphicScene) { static init(app: IGraphicScene) {
return new PlatformOperateInteraction(app); return new PlatformOperateInteraction(app);
@ -196,37 +118,4 @@ export class PlatformOperateInteraction extends GraphicInteractionPlugin<Platfor
onLeftClick() { onLeftClick() {
useLineStore().stateProCountIncrease(); useLineStore().stateProCountIncrease();
} }
// onContextMenu(e: FederatedMouseEvent) {
// const target = e.target as DisplayObject;
// const platform = target.getGraphic() as Platform;
// this.app.updateSelected(platform);
// holdConfig.handler = () => {
// platform.states.upOccHold = true;
// platform.states.emergstop = true;
// platform.doRepaint();
// };
// removeHoldrConfig.handler = () => {
// platform.states.upOccHold = false;
// platform.states.emergstop = false;
// platform.doRepaint();
// };
// skipStopConfig.handler = () => {
// platform.states.upSkipstop = true;
// platform.doRepaint();
// };
// removeSkipStopConfig.handler = () => {
// platform.states.upSkipstop = false;
// platform.doRepaint();
// };
// dockTimeConfig.handler = () => {
// platform.states.stopTime = 30;
// platform.doRepaint();
// };
// operatingLevelConfig.handler = () => {
// platform.states.nextSectionRunLevel = 2;
// platform.doRepaint();
// };
// PlatformOperateMenu.open(e.global);
// }
} }

View File

@ -5,6 +5,8 @@ import { Turnout, TurnoutPort } from './turnout/Turnout';
import { Section, SectionPort } from './section/Section'; import { Section, SectionPort } from './section/Section';
import { TrainWindow } from './trainWindow/TrainWindow'; import { TrainWindow } from './trainWindow/TrainWindow';
import { AxleCounting } from './axleCounting/AxleCounting'; import { AxleCounting } from './axleCounting/AxleCounting';
import { Station } from './station/Station';
import { ScreenDoor } from './screenDoor/ScreenDoor';
/** /**
* *
* @param polygon * @param polygon
@ -85,6 +87,8 @@ export function createRelatedRefProto(
[Turnout.Type, graphicData.RelatedRef.DeviceType.Turnout], [Turnout.Type, graphicData.RelatedRef.DeviceType.Turnout],
[TrainWindow.Type, graphicData.RelatedRef.DeviceType.TrainWindow], [TrainWindow.Type, graphicData.RelatedRef.DeviceType.TrainWindow],
[AxleCounting.Type, graphicData.RelatedRef.DeviceType.AxleCounting], [AxleCounting.Type, graphicData.RelatedRef.DeviceType.AxleCounting],
[Station.Type, graphicData.RelatedRef.DeviceType.station],
[ScreenDoor.Type, graphicData.RelatedRef.DeviceType.ScreenDoor],
]); ]);
const protoDeviceType = typeMap.get(type); const protoDeviceType = typeMap.get(type);
if (protoDeviceType === undefined) throw Error(`输入的type有误: ${type}`); if (protoDeviceType === undefined) throw Error(`输入的type有误: ${type}`);

View File

@ -1,91 +1,38 @@
import { Color, Container, Graphics, Point, Rectangle } from 'pixi.js'; import { Color, Container, Graphics, Rectangle } from 'pixi.js';
import { import {
GraphicAnimation, GraphicAnimation,
GraphicData, GraphicData,
GraphicState, GraphicState,
JlGraphic, JlGraphic,
JlGraphicTemplate, JlGraphicTemplate,
VectorText, distance2,
calculateMirrorPoint,
getRectangleCenter, getRectangleCenter,
} from 'src/jl-graphic'; } from 'src/jl-graphic';
import { Station } from '../station/Station'; import { Station } from '../station/Station';
import { createRelatedRefProto } from '../CommonGraphics';
import { IRelatedRefData } from '../CommonGraphics';
import { Section } from '../section/Section';
export interface IPlatformData extends GraphicData { export interface IPlatformData extends GraphicData {
get code(): string; // 编号 get code(): string; // 编号
set code(v: string); set code(v: string);
get index(): number; get index(): number;
set index(v: number); set index(v: number);
get refStation(): string; // 关联的车站 get platformRef(): IRelatedRefData[]; // 关联的车站和物理区段
set refStation(v: string); set platformRef(v: IRelatedRefData[]);
clone(): IPlatformData; clone(): IPlatformData;
copyFrom(data: IPlatformData): void; copyFrom(data: IPlatformData): void;
eq(other: IPlatformData): boolean; eq(other: IPlatformData): boolean;
} }
export interface IPlatformState extends GraphicState { export interface IPlatformState extends GraphicState {
id?: string; id?: string;
// get emergstop(): boolean; //紧急关闭
// set emergstop(v: boolean);
// get trainberth(): boolean; //列车停站
// set trainberth(v: boolean);
// get close(): boolean; //站台关闭,清客
// set close(v: boolean);
// get upHold(): boolean; //上行方向车站扣车
// set upHold(v: boolean);
// get downHold(): boolean; //下行方向车站扣车
// set downHold(v: boolean);
// get upOccHold(): boolean; //上行方向中心扣车
// set upOccHold(v: boolean);
// get downOccHold(): boolean; //下行方向中心扣车
// set downOccHold(v: boolean);
// get psdOpen(): boolean; //屏蔽门开
// set psdOpen(v: boolean);
// get psdCut(): boolean; //屏蔽门切除
// set psdCut(v: boolean);
// get upSkipstop(): boolean; //上行方向跳停
// set upSkipstop(v: boolean);
// get downSkipstop(): boolean; //下行方向跳停
// set downSkipstop(v: boolean);
// get upTrainSkipstop(): boolean; //上行方向指定列车跳停
// set upTrainSkipstop(v: boolean);
// get downTrainSkipstop(): boolean; //下行方向指定列车跳停
// set downTrainSkipstop(v: boolean);
// get nextSectionRunTime(): number; //下一区间运行时间
// set nextSectionRunTime(v: number);
// get nextSectionRunLevel(): number; //下一区间运行等级
// set nextSectionRunLevel(v: number);
// get stopTime(): number; //停站时间
// set stopTime(v: number);
}
//站台颜色
export enum PlatformColorEnum {
grey = '0x7F7F7F', //站台没有列车停站
yellow = '0xfbff00', //列车在站台停站
blue = '0xC0C0FE', //列车在站台跳停
white = '0xffffff',
lozengeRed = '0xff0000', //站台旁的菱形图标
whiteNumbers = '0xffffff', //站台旁白色数字
whiteCircle = '0xffffff', //H字符旁的圆圈
HCharYellow = '0xfbff00', //站台旁的扣字
HCharWhite = '0xffffff',
HCharRed = '0xff0000',
SCharBlue = '0x00FFCC', ////站台旁的跳字
doorGreen = '0x00FF00', //屏蔽门的颜色
doorRed = '0xff0000',
doorBlue = '0x4048C4',
} }
const platformConsts = { const platformConsts = {
width: 90, width: 90,
height: 20, height: 20,
lineWidth: 3, lineWidth: 3,
besideFontSize: 12, white: '0xffffff', //站台颜色
doorOpenSpacing: 15,
doorPlatformSpacing: 17,
besideSpacing: 10,
circleRadius: 9,
smallDoorWidth: 10,
}; };
//子元素--矩形 //子元素--矩形
@ -99,171 +46,22 @@ export class rectGraphic extends Container {
} }
draw(state: IPlatformState): void { draw(state: IPlatformState): void {
const rectGraphic = this.rectGraphic; const rectGraphic = this.rectGraphic;
rectGraphic.clear(); const fillColor = platformConsts.white;
const fillColor = PlatformColorEnum.white; rectGraphic
if (state) { .clear()
// fillColor = PlatformColorEnum.yellow; .lineStyle(platformConsts.lineWidth, new Color(fillColor))
} .beginFill(fillColor, 1)
// if (state.upSkipstop || state.downSkipstop) { .drawRect(0, 0, platformConsts.width, platformConsts.height).endFill;
// fillColor = PlatformColorEnum.grey; rectGraphic.pivot = getRectangleCenter(
// } new Rectangle(0, 0, platformConsts.width, platformConsts.height)
rectGraphic.lineStyle(platformConsts.lineWidth, new Color(fillColor));
rectGraphic.beginFill(fillColor, 1);
rectGraphic.drawRect(0, 0, platformConsts.width, platformConsts.height);
rectGraphic.endFill;
const rectP = new Rectangle(
0,
0,
platformConsts.width,
platformConsts.height
); );
rectGraphic.pivot = getRectangleCenter(rectP);
} }
clear(): void { clear(): void {
this.rectGraphic.clear(); this.rectGraphic.clear();
} }
} }
//子元素--字符
class codeGraph extends Container {
static Type = 'Code';
hold: VectorText = new VectorText(''); //扣车
runLevel: VectorText = new VectorText(''); //运行等级
runTime: VectorText = new VectorText(''); //运行时间
stopTime: VectorText = new VectorText(''); //停站时间
skipStop: VectorText = new VectorText(''); //调停
circle: Graphics = new Graphics();
constructor() {
super();
this.addChild(this.hold);
this.addChild(this.runLevel);
this.addChild(this.stopTime);
this.addChild(this.runTime);
this.addChild(this.skipStop);
this.addChild(this.circle);
this.hold.setVectorFontSize(platformConsts.besideFontSize);
this.runLevel.setVectorFontSize(platformConsts.besideFontSize);
this.stopTime.setVectorFontSize(platformConsts.besideFontSize);
this.runTime.setVectorFontSize(platformConsts.besideFontSize);
this.skipStop.setVectorFontSize(platformConsts.besideFontSize);
}
draw(): void {
//扣车
const hold = this.hold;
hold.text = '扣';
hold.anchor.set(0.5);
hold.position.set(
-platformConsts.width / 2 -
platformConsts.lineWidth / 2 -
(platformConsts.besideSpacing * 2) / 3,
-(platformConsts.height * 3) / 4
);
hold.style.fill = PlatformColorEnum.HCharWhite;
//区间运行等级状态
const runLevel = this.runLevel;
runLevel.anchor.set(0.5);
runLevel.position.set(
-platformConsts.width / 2 -
platformConsts.lineWidth / 2 -
platformConsts.besideSpacing,
(-platformConsts.height * 4) / 5
);
runLevel.style.fill = PlatformColorEnum.yellow;
//区间运行时间
const runTime = this.runTime;
runTime.anchor.set(0.5);
runTime.position.set(
platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
platformConsts.besideSpacing,
-platformConsts.besideSpacing
);
runTime.style.fill = PlatformColorEnum.whiteNumbers;
//停站时间
const stopTime = this.stopTime;
stopTime.anchor.set(0.5);
stopTime.position.set(
-platformConsts.width / 2 -
platformConsts.lineWidth / 2 -
platformConsts.besideSpacing,
0
);
stopTime.style.fill = PlatformColorEnum.whiteNumbers;
//跳停
const skipStop = this.skipStop;
skipStop.text = '跳';
skipStop.anchor.set(0.5);
const ps = calculateMirrorPoint(new Point(0, 0), hold.position);
skipStop.position.set(ps.x + 4, ps.y);
skipStop.style.fill = PlatformColorEnum.SCharBlue;
const circle = this.circle;
circle.clear();
circle.lineStyle(1, PlatformColorEnum.SCharBlue);
circle.drawCircle(0, 0, platformConsts.circleRadius);
circle.position.copyFrom(skipStop.position);
hold.visible = false;
runLevel.visible = false;
stopTime.visible = false;
runTime.visible = false;
skipStop.visible = false;
circle.visible = false;
}
clear(): void {
this.hold.destroy();
}
// changeState(stateData: IPlatformState): void {
// if (
// stateData.upHold ||
// stateData.upOccHold ||
// stateData.downHold ||
// stateData.downOccHold
// ) {
// this.hold.text = '扣';
// this.hold.visible = true;
// //上行扣车
// if (stateData.upHold) {
// this.hold.style.fill = PlatformColorEnum.HCharYellow;
// }
// if (stateData.upOccHold) {
// this.hold.style.fill = PlatformColorEnum.HCharWhite;
// }
// if (stateData.upHold && stateData.upOccHold) {
// this.hold.style.fill = PlatformColorEnum.HCharRed;
// }
// //下行扣车
// if (stateData.downHold) {
// this.hold.style.fill = PlatformColorEnum.HCharYellow;
// }
// if (stateData.downOccHold) {
// this.hold.style.fill = PlatformColorEnum.HCharWhite;
// }
// if (stateData.downHold && stateData.downOccHold) {
// this.hold.style.fill = PlatformColorEnum.HCharRed;
// }
// }
// //运行等级
// if (stateData.nextSectionRunLevel) {
// this.runLevel.visible = true;
// this.runLevel.text = stateData.nextSectionRunLevel;
// }
// //运行时间
// if (stateData.nextSectionRunTime) {
// this.runTime.visible = false;
// this.runTime.text = stateData.nextSectionRunTime;
// }
// //停站时间
// if (stateData.stopTime) {
// this.stopTime.visible = true;
// this.stopTime.text = stateData.stopTime;
// }
// //跳停
// if (stateData.upSkipstop || stateData.downSkipstop) {
// this.skipStop.visible = true;
// this.circle.visible = true;
// }
// }
}
//子元素--站台旁菱形图标 //子元素--站台旁菱形图标
class emergClose extends JlGraphic { /* class emergClose extends JlGraphic {
static Type = 'emergClose'; static Type = 'emergClose';
lozenge: Graphics; lozenge: Graphics;
deltaTime = 0; deltaTime = 0;
@ -316,32 +114,28 @@ class emergClose extends JlGraphic {
}); });
return flashAnmiation; return flashAnmiation;
} }
// changeState(id: string, stateData: IPlatformState): void { changeState(id: string, stateData: IPlatformState): void {
// let redFlash = this.animation(`${id}emergClose_red_flash`); let redFlash = this.animation(`${id}emergClose_red_flash`);
// if (stateData.emergstop) { if (stateData.emergstop) {
// if (!redFlash) { if (!redFlash) {
// redFlash = this.createFlashAnmiation(`${id}emergClose_red_flash`); redFlash = this.createFlashAnmiation(`${id}emergClose_red_flash`);
// this.addAnimation(redFlash); this.addAnimation(redFlash);
// } }
// redFlash.resume(); redFlash.resume();
// } else { } else {
// if (redFlash) { if (redFlash) {
// redFlash.pause(); redFlash.pause();
// } }
// } }
// } }
} } */
export class Platform extends JlGraphic { export class Platform extends JlGraphic {
static Type = 'Platform'; static Type = 'Platform';
platformGraphic: rectGraphic = new rectGraphic(); rectGraphic: rectGraphic = new rectGraphic();
emergClose: emergClose = new emergClose();
codeGraph: codeGraph = new codeGraph();
constructor() { constructor() {
super(Platform.Type); super(Platform.Type);
this.addChild(this.platformGraphic); this.addChild(this.rectGraphic);
this.addChild(this.emergClose);
this.addChild(this.codeGraph);
} }
get datas(): IPlatformData { get datas(): IPlatformData {
@ -354,27 +148,7 @@ export class Platform extends JlGraphic {
return this.datas.index + ''; return this.datas.index + '';
} }
doRepaint(): void { doRepaint(): void {
this.platformGraphic.draw(this.states); this.rectGraphic.draw(this.states);
this.emergClose.draw();
this.codeGraph.draw();
this.emergClose.position.set(
0,
-platformConsts.height / 2 -
platformConsts.doorPlatformSpacing -
platformConsts.height / 3
);
this.codeGraph.position.set(0, 0);
//站台方向
/* if (this.datas.direction == 'down') {
const psChange = [
this.emergClose,
...this.codeGraph.children,
];
psChange.forEach((g) => {
g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position));
});
} */
// this.changeState();
} }
buildRelation() { buildRelation() {
const stationas = this.queryStore.queryByType<Station>(Station.Type); const stationas = this.queryStore.queryByType<Station>(Station.Type);
@ -385,40 +159,58 @@ export class Platform extends JlGraphic {
break; break;
} }
} }
const sections = this.queryStore.queryByType<Section>(Section.Type);
const minDistanceRefSections: Section[] = [];
sections.forEach((section) => {
const sP = section.localBoundsToCanvasPoints();
if (this.x > sP[0].x && this.x < sP[1].x) {
minDistanceRefSections.push(section);
}
});
const refSection = minDistanceRefSections.reduce((prev, cur) => {
return distance2(prev.position, this.position) >
distance2(cur.position, this.position)
? cur
: prev;
});
if (refSection) {
this.relationManage.addRelation(this, refSection);
}
} }
saveRelations() { saveRelations() {
const platformRef = [];
const refStation = this.relationManage const refStation = this.relationManage
.getRelationsOfGraphicAndOtherType(this, Station.Type) .getRelationsOfGraphicAndOtherType(this, Station.Type)
.map((relation) => relation.getOtherGraphic<Station>(this).datas.id); .map((relation) => relation.getOtherGraphic<Station>(this).datas.id);
if (refStation.length) { if (refStation.length) {
this.datas.refStation = refStation[0]; platformRef.push(createRelatedRefProto(Station.Type, refStation[0]));
} }
const refSection = this.relationManage
.getRelationsOfGraphicAndOtherType(this, Section.Type)
.map((relation) => relation.getOtherGraphic<Section>(this).datas.id);
if (refStation.length) {
platformRef.push(createRelatedRefProto(Section.Type, refSection[0]));
}
this.datas.platformRef = platformRef;
} }
loadRelations() { loadRelations() {
if (this.datas.refStation) { if (this.datas.platformRef.length) {
this.relationManage.addRelation( this.datas.platformRef.forEach((device) => {
this, this.relationManage.addRelation(
this.queryStore.queryById<Station>(this.datas.refStation) this,
); this.queryStore.queryById(device.id)
);
});
} }
} }
// changeState(): void {
// this.doorGraphic.changeState(this.states);
// this.emergClose.changeState(this.id, this.states);
// this.codeGraph.changeState(this.states);
// }
} }
export class PlatformTemplate extends JlGraphicTemplate<Platform> { export class PlatformTemplate extends JlGraphicTemplate<Platform> {
hasdoor: boolean;
direction: string;
constructor(dataTemplate: IPlatformData, stateTemplate: IPlatformState) { constructor(dataTemplate: IPlatformData, stateTemplate: IPlatformState) {
super(Platform.Type, { super(Platform.Type, {
dataTemplate, dataTemplate,
stateTemplate, stateTemplate,
}); });
this.hasdoor = true;
this.direction = 'up';
} }
new(): Platform { new(): Platform {
const platform = new Platform(); const platform = new Platform();

View File

@ -37,9 +37,6 @@ export class PlatformDraw extends GraphicDrawAssistant<
this.platformGraphic.doRepaint(); this.platformGraphic.doRepaint();
} }
clearCache(): void {
//this.platformGraphic.clear();
}
onLeftDown(e: FederatedPointerEvent): void { onLeftDown(e: FederatedPointerEvent): void {
this.container.position.copyFrom(this.toCanvasCoordinates(e.global)); this.container.position.copyFrom(this.toCanvasCoordinates(e.global));
this.createAndStore(true); this.createAndStore(true);

View File

@ -117,14 +117,10 @@ export class ScreenDoor extends JlGraphic {
} }
export class ScreenDoorTemplate extends JlGraphicTemplate<ScreenDoor> { export class ScreenDoorTemplate extends JlGraphicTemplate<ScreenDoor> {
hasdoor: boolean;
direction: string;
constructor(dataTemplate: IScreenDoorData) { constructor(dataTemplate: IScreenDoorData) {
super(ScreenDoor.Type, { super(ScreenDoor.Type, {
dataTemplate, dataTemplate,
}); });
this.hasdoor = true;
this.direction = 'up';
} }
new(): ScreenDoor { new(): ScreenDoor {
const screenDoor = new ScreenDoor(); const screenDoor = new ScreenDoor();

View File

@ -53,12 +53,11 @@ function buildAbsorbablePositions(
): AbsorbablePosition[] { ): AbsorbablePosition[] {
const aps: AbsorbablePosition[] = []; const aps: AbsorbablePosition[] = [];
const platforms = screenDoor.queryStore.queryByType<Platform>(Platform.Type); const platforms = screenDoor.queryStore.queryByType<Platform>(Platform.Type);
const { width, height } = screenDoor.getGraphicApp().canvas; const { height } = screenDoor.getGraphicApp().canvas;
platforms.forEach((platform) => { platforms.forEach((platform) => {
const ps = platform.datas.transform.position; const ps = platform.datas.transform.position;
const xs = new AbsorbableLine({ x: 0, y: ps.y }, { x: width, y: ps.y });
const ys = new AbsorbableLine({ x: ps.x, y: 0 }, { x: ps.x, y: height }); const ys = new AbsorbableLine({ x: ps.x, y: 0 }, { x: ps.x, y: height });
aps.push(xs, ys); aps.push(ys);
}); });
return aps; return aps;
} }

View File

@ -1315,10 +1315,10 @@ export namespace graphicData {
common?: CommonInfo; common?: CommonInfo;
code?: string; code?: string;
index?: number; index?: number;
refStation?: string; platformRef?: RelatedRef[];
}) { }) {
super(); super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [8], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") { if (!Array.isArray(data) && typeof data == "object") {
if ("common" in data && data.common != undefined) { if ("common" in data && data.common != undefined) {
this.common = data.common; this.common = data.common;
@ -1329,8 +1329,8 @@ export namespace graphicData {
if ("index" in data && data.index != undefined) { if ("index" in data && data.index != undefined) {
this.index = data.index; this.index = data.index;
} }
if ("refStation" in data && data.refStation != undefined) { if ("platformRef" in data && data.platformRef != undefined) {
this.refStation = data.refStation; this.platformRef = data.platformRef;
} }
} }
} }
@ -1355,17 +1355,17 @@ export namespace graphicData {
set index(value: number) { set index(value: number) {
pb_1.Message.setField(this, 5, value); pb_1.Message.setField(this, 5, value);
} }
get refStation() { get platformRef() {
return pb_1.Message.getFieldWithDefault(this, 8, "") as string; return pb_1.Message.getRepeatedWrapperField(this, RelatedRef, 8) as RelatedRef[];
} }
set refStation(value: string) { set platformRef(value: RelatedRef[]) {
pb_1.Message.setField(this, 8, value); pb_1.Message.setRepeatedWrapperField(this, 8, value);
} }
static fromObject(data: { static fromObject(data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>; common?: ReturnType<typeof CommonInfo.prototype.toObject>;
code?: string; code?: string;
index?: number; index?: number;
refStation?: string; platformRef?: ReturnType<typeof RelatedRef.prototype.toObject>[];
}): Platform { }): Platform {
const message = new Platform({}); const message = new Platform({});
if (data.common != null) { if (data.common != null) {
@ -1377,8 +1377,8 @@ export namespace graphicData {
if (data.index != null) { if (data.index != null) {
message.index = data.index; message.index = data.index;
} }
if (data.refStation != null) { if (data.platformRef != null) {
message.refStation = data.refStation; message.platformRef = data.platformRef.map(item => RelatedRef.fromObject(item));
} }
return message; return message;
} }
@ -1387,7 +1387,7 @@ export namespace graphicData {
common?: ReturnType<typeof CommonInfo.prototype.toObject>; common?: ReturnType<typeof CommonInfo.prototype.toObject>;
code?: string; code?: string;
index?: number; index?: number;
refStation?: string; platformRef?: ReturnType<typeof RelatedRef.prototype.toObject>[];
} = {}; } = {};
if (this.common != null) { if (this.common != null) {
data.common = this.common.toObject(); data.common = this.common.toObject();
@ -1398,8 +1398,8 @@ export namespace graphicData {
if (this.index != null) { if (this.index != null) {
data.index = this.index; data.index = this.index;
} }
if (this.refStation != null) { if (this.platformRef != null) {
data.refStation = this.refStation; data.platformRef = this.platformRef.map((item: RelatedRef) => item.toObject());
} }
return data; return data;
} }
@ -1413,8 +1413,8 @@ export namespace graphicData {
writer.writeString(2, this.code); writer.writeString(2, this.code);
if (this.index != 0) if (this.index != 0)
writer.writeInt32(5, this.index); writer.writeInt32(5, this.index);
if (this.refStation.length) if (this.platformRef.length)
writer.writeString(8, this.refStation); writer.writeRepeatedMessage(8, this.platformRef, (item: RelatedRef) => item.serialize(writer));
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -1434,7 +1434,7 @@ export namespace graphicData {
message.index = reader.readInt32(); message.index = reader.readInt32();
break; break;
case 8: case 8:
message.refStation = reader.readString(); reader.readMessage(message.platformRef, () => pb_1.Message.addToRepeatedWrapperField(message, 8, RelatedRef.deserialize(reader), RelatedRef));
break; break;
default: reader.skipField(); default: reader.skipField();
} }
@ -3275,7 +3275,9 @@ export namespace graphicData {
TrainWindow = 2, TrainWindow = 2,
AxleCounting = 3, AxleCounting = 3,
SectionLink = 4, SectionLink = 4,
signal = 5 signal = 5,
station = 6,
ScreenDoor = 7
} }
export enum DevicePort { export enum DevicePort {
A = 0, A = 0,