diff --git a/components/Platform/Platform.d.ts b/components/Platform/Platform.d.ts index ea1df02..0ddc4a6 100644 --- a/components/Platform/Platform.d.ts +++ b/components/Platform/Platform.d.ts @@ -1,30 +1,55 @@ -import { JlGraphic, JlGraphicTemplate } from "jl-graphic"; +import { JlGraphic, JlGraphicTemplate, VectorText } from "jl-graphic"; import { Container, Graphics } from 'pixi.js'; -import { CategoryType, DoorConstsConfig, IPlatformData, IPlatformState, PlatformConstsConfig } from './PlatformConfig'; +import { CategoryType, IBriJingPlatformState, IPlatformData, IXiAnPlatformState, PlatformConstsConfig } from './PlatformConfig'; +type IPlatformState = IBriJingPlatformState | IXiAnPlatformState; declare class RectGraphic extends Container { static Type: string; rectGraphic: Graphics; constructor(); - draw(platformConsts: PlatformConstsConfig): void; + draw(state: IPlatformState, platformConsts: PlatformConstsConfig): void; clear(): void; } -declare class DoorGraphic extends Container { +export declare class DoorGraphic extends Container { static Type: string; doorGraphic: Graphics; doorCloseGraphic: Graphics; constructor(); - draw(platformConsts: PlatformConstsConfig, doorConstsConfig: DoorConstsConfig): void; + draw(stateData: IXiAnPlatformState, ipRtuStusDown: boolean, platformConsts: PlatformConstsConfig): void; clear(): void; + changeState(stateData: IXiAnPlatformState): void; +} +declare class CodeGraph extends Container { + static Type: string; + character: VectorText; + runLevel: VectorText; + runTime: VectorText; + stopTime: VectorText; + circle: Graphics; + constructor(platformConsts: PlatformConstsConfig); + draw(platformConsts: PlatformConstsConfig): void; + clear(): void; + changeState(stateData: IXiAnPlatformState, platformConsts: PlatformConstsConfig): void; +} +declare class LozengeGraphic extends Container { + static Type: string; + lozengeGraphic: Graphics; + constructor(); + draw(platformConsts: PlatformConstsConfig): void; + clear(): void; + changeState(stateData: IXiAnPlatformState): void; } export declare class Platform extends JlGraphic { static Type: string; private categoryType; rectGraphic: RectGraphic; - doorGraphic: DoorGraphic; + doorGraphic?: DoorGraphic; + lozengeGraphic?: LozengeGraphic; + codeGraph?: CodeGraph; constructor(categoryType: CategoryType); get datas(): IPlatformData; get states(): IPlatformState; doRepaint(): void; + changeState(): void; } export declare class PlatformTemplate extends JlGraphicTemplate { categoryType: CategoryType; diff --git a/components/Platform/Platform.js b/components/Platform/Platform.js index 4552c0d..8563611 100644 --- a/components/Platform/Platform.js +++ b/components/Platform/Platform.js @@ -1,6 +1,6 @@ -import { JlGraphic, JlGraphicTemplate, getRectangleCenter } from 'jl-graphic'; -import { Container, Graphics, Color, Rectangle } from 'pixi.js'; -import { platformConstsMap } from './PlatformConfig.js'; +import { JlGraphic, calculateMirrorPoint, JlGraphicTemplate, getRectangleCenter, VectorText } from 'jl-graphic'; +import { Container, Graphics, Color, Point, Rectangle } from 'pixi.js'; +import { CategoryType, platformConstsMap } from './PlatformConfig.js'; class RectGraphic extends Container { static Type = 'RectPlatForm'; @@ -10,9 +10,18 @@ class RectGraphic extends Container { this.rectGraphic = new Graphics(); this.addChild(this.rectGraphic); } - draw(platformConsts) { + draw(state, platformConsts) { const rectGraphic = this.rectGraphic; - const fillColor = platformConsts.rectColor; + rectGraphic.clear(); + let fillColor = platformConsts.grey; + /* if(state instanceof IXiAnPlatformState){ + if (state.trainberth) { + fillColor = platformConsts.yellow; + } + if (state.upSkipstop || state.downSkipstop) { + fillColor = platformConsts.blue; + } + } */ rectGraphic .clear() .lineStyle(platformConsts.lineWidth, new Color(fillColor)) @@ -24,6 +33,7 @@ class RectGraphic extends Container { this.rectGraphic.clear(); } } +//子元素--门 class DoorGraphic extends Container { static Type = 'Door'; doorGraphic; @@ -35,53 +45,276 @@ class DoorGraphic extends Container { this.addChild(this.doorGraphic); this.addChild(this.doorCloseGraphic); } - draw(platformConsts, doorConstsConfig) { + draw(stateData, ipRtuStusDown, platformConsts) { + const doorConsts = platformConsts.doorGraphic; const doorGraphic = this.doorGraphic; const doorCloseGraphic = this.doorCloseGraphic; - let lineColor = doorConstsConfig.doorGreen; - doorGraphic.clear() - .lineStyle(platformConsts.lineWidth, new Color(lineColor)) - .moveTo(-platformConsts.width / 2 - platformConsts.lineWidth / 2, 0) - .lineTo(-doorConstsConfig.doorOpenSpacing, 0) - .moveTo(doorConstsConfig.doorOpenSpacing, 0) - .lineTo(platformConsts.width / 2 + platformConsts.lineWidth / 2, 0); + doorGraphic.clear(); + doorCloseGraphic.clear(); + let lineColor = doorConsts.doorGreen; + if (ipRtuStusDown) { + lineColor = doorConsts.blueShowColor; + } + else if (stateData.psdCut) { + lineColor = doorConsts.doorRed; + } + doorGraphic.lineStyle(platformConsts.lineWidth, new Color(lineColor)); + doorGraphic.moveTo(-platformConsts.width / 2 - platformConsts.lineWidth / 2, 0); + doorGraphic.lineTo(-doorConsts.doorOpenSpacing, 0); + doorGraphic.moveTo(doorConsts.doorOpenSpacing, 0); + doorGraphic.lineTo(platformConsts.width / 2 + platformConsts.lineWidth / 2, 0); //屏蔽门闭合 - doorCloseGraphic.clear() - .lineStyle(platformConsts.lineWidth, new Color(lineColor)) - .moveTo(-doorConstsConfig.doorOpenSpacing, 0) - .lineTo(doorConstsConfig.doorOpenSpacing, 0); + doorCloseGraphic.lineStyle(platformConsts.lineWidth, new Color(lineColor)); + doorCloseGraphic.moveTo(-doorConsts.doorOpenSpacing, 0); + doorCloseGraphic.lineTo(doorConsts.doorOpenSpacing, 0); } clear() { this.doorGraphic.clear(); this.doorCloseGraphic.clear(); } + changeState(stateData) { + if (stateData.psdOpen) { + this.doorCloseGraphic.visible = false; + } + else { + this.doorCloseGraphic.visible = true; + } + } +} +//子元素--字符 +class CodeGraph extends Container { + static Type = 'Code'; + character = new VectorText(''); //扣车H + runLevel = new VectorText(''); //运行等级 + runTime = new VectorText(''); //运行时间 + stopTime = new VectorText(''); //停站时间 + circle = new Graphics(); + constructor(platformConsts) { + super(); + this.addChild(this.character); + this.addChild(this.runLevel); + this.addChild(this.circle); + this.addChild(this.stopTime); + this.addChild(this.runTime); + const codeConsts = platformConsts.codeGraphic; + this.character.setVectorFontSize(codeConsts.besideFontSize); + this.runLevel.setVectorFontSize(codeConsts.besideFontSize); + this.stopTime.setVectorFontSize(codeConsts.besideFontSize); + this.runTime.setVectorFontSize(codeConsts.besideFontSize); + } + draw(platformConsts) { + const codeConsts = platformConsts.codeGraphic; + //扣车 + const character = this.character; + character.text = 'H'; + character.anchor.set(0.5); + character.position.set(-platformConsts.width / 2 - + platformConsts.lineWidth / 2 - + (codeConsts.besideSpacing * 2) / 3, (platformConsts.height * 3) / 4); + character.style.fill = codeConsts.whiteNumbers; + const circle = this.circle; + circle.clear(); + circle.lineStyle(0.5, codeConsts.whiteCircle); + circle.drawCircle(0, 0, codeConsts.circleRadius); + circle.position.set(-platformConsts.width / 2 - + platformConsts.lineWidth / 2 - + (codeConsts.besideSpacing * 4) / 3, (platformConsts.height * 3) / 5); + //区间运行等级状态 + const runLevel = this.runLevel; + runLevel.anchor.set(0.5); + runLevel.position.set(platformConsts.width / 2 + + platformConsts.lineWidth / 2 + + 3 * codeConsts.besideSpacing, -codeConsts.besideSpacing); + runLevel.style.fill = codeConsts.whiteNumbers; + //区间运行时间 + const runTime = this.runTime; + runTime.anchor.set(0.5); + runTime.position.set(platformConsts.width / 2 + + platformConsts.lineWidth / 2 + + codeConsts.besideSpacing, -codeConsts.besideSpacing); + runTime.style.fill = codeConsts.whiteNumbers; + //停站时间 + const stopTime = this.stopTime; + stopTime.anchor.set(0.5); + stopTime.position.set(platformConsts.width / 2 + + platformConsts.lineWidth / 2 + + codeConsts.besideSpacing, codeConsts.besideSpacing); + stopTime.style.fill = codeConsts.whiteNumbers; + character.visible = false; + circle.visible = false; + runLevel.visible = false; + stopTime.visible = false; + runTime.visible = false; + } + clear() { + this.character.destroy(); + } + changeState(stateData, platformConsts) { + const codeConsts = platformConsts.codeGraphic; + if (stateData.upHold || + stateData.upOccHold || + stateData.downHold || + stateData.downOccHold) { + this.character.text = 'H'; + this.character.visible = true; + this.circle.visible = true; + //上行扣车 + if (stateData.upHold) { + this.character.style.fill = codeConsts.HCharYellow; + } + if (stateData.upOccHold) { + this.character.style.fill = codeConsts.HCharWhite; + } + if (stateData.upHold && stateData.upOccHold) { + this.character.style.fill = codeConsts.HCharRed; + } + //下行扣车 + if (stateData.downHold) { + this.character.style.fill = codeConsts.HCharYellow; + } + if (stateData.downOccHold) { + this.character.style.fill = codeConsts.HCharWhite; + } + if (stateData.downHold && stateData.downOccHold) { + this.character.style.fill = codeConsts.HCharRed; + } + } + //运行等级 + if (stateData.nextSectionRunLevel) { + this.runLevel.visible = false; + this.runLevel.text = stateData.nextSectionRunLevel; + } + //运行时间 + if (stateData.nextSectionRunTime) { + this.runTime.visible = true; + this.runTime.text = stateData.nextSectionRunTime; + } + //停站时间 + if (stateData.stopTime) { + this.stopTime.visible = true; + this.stopTime.text = stateData.stopTime; + } + } +} +//子元素--站台旁菱形图标 +class LozengeGraphic extends Container { + static Type = 'lozengeGraphic'; + lozengeGraphic; + constructor() { + super(); + this.lozengeGraphic = new Graphics(); + this.addChild(this.lozengeGraphic); + } + draw(platformConsts) { + const LozengeConsts = platformConsts.lozengeGraphic; + const lozengeGraphic = this.lozengeGraphic; + lozengeGraphic.clear(); + lozengeGraphic.lineStyle(1, new Color(LozengeConsts.lozengeRed)); + lozengeGraphic.beginFill(LozengeConsts.lozengeRed, 1); + lozengeGraphic.drawRect(0, 0, platformConsts.height / 4, platformConsts.height / 4); + lozengeGraphic.endFill(); + const rect = new Rectangle(0, 0, platformConsts.height / 4, platformConsts.height / 4); + lozengeGraphic.pivot = getRectangleCenter(rect); + lozengeGraphic.rotation = Math.PI / 4; + lozengeGraphic.visible = false; + } + clear() { + this.lozengeGraphic.clear(); + } + changeState(stateData) { + if (stateData.emergstop) { + this.lozengeGraphic.visible = true; + } + else { + this.lozengeGraphic.visible = false; + } + } } class Platform extends JlGraphic { static Type = 'Platform'; categoryType; rectGraphic = new RectGraphic(); - doorGraphic = new DoorGraphic(); + doorGraphic; + lozengeGraphic; + codeGraph; constructor(categoryType) { super(Platform.Type); this.categoryType = categoryType; this.addChild(this.rectGraphic); - this.addChild(this.doorGraphic); + if (categoryType == CategoryType.XiAn) { + const platformConsts = platformConstsMap.get(this.categoryType); + this.doorGraphic = new DoorGraphic(); + this.lozengeGraphic = new LozengeGraphic(); + this.codeGraph = new CodeGraph(platformConsts); + this.addChild(this.doorGraphic); + this.addChild(this.codeGraph); + this.addChild(this.lozengeGraphic); + } } get datas() { return this.getDatas(); } get states() { - return this.getStates(); + if (this.categoryType == CategoryType.BeiJing) { + return this.getStates(); + } + else { + return this.getStates(); + } } doRepaint() { - this.doorGraphic.clear(); + this.doorGraphic?.clear(); const platformConsts = platformConstsMap.get(this.categoryType); - if (platformConsts) { - this.rectGraphic.draw(platformConsts); - if (platformConsts.doorGraphic) { - this.doorGraphic.draw(platformConsts, platformConsts.doorGraphic); - } + this.rectGraphic.draw(this.states, platformConsts); + if (this.doorGraphic) { + const states = this.states; + /* const station = this.getGraphicApp().queryStore.queryByCodeAndType( + states.rtuId > 9 ? '' + states.rtuId : '0' + states.rtuId, + Station.Type + ); */ + this.doorGraphic.draw(states, false, platformConsts); + const doorConsts = platformConsts.doorGraphic; + this.doorGraphic.position.set(0, -platformConsts.height / 2 - doorConsts.doorPlatformSpacing); } + if (this.codeGraph) { + this.codeGraph.draw(platformConsts); + this.codeGraph.position.set(0, 0); + } + if (this.lozengeGraphic) { + const LozengeConsts = platformConsts.lozengeGraphic; + this.lozengeGraphic.draw(platformConsts); + this.lozengeGraphic.position.set(0, -platformConsts.height / 2 - + LozengeConsts.doorPlatformSpacing - + platformConsts.height / 3); + } + //站台方向 + if (this.datas.direction == 'down') { + const psChange = [ + this.doorGraphic, + this.lozengeGraphic, + this.codeGraph?.children[0], + this.codeGraph?.children[1], + this.codeGraph?.children[3], + this.codeGraph?.children[4], + ]; + psChange.forEach((g) => { + if (g) { + g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position)); + } + }); + const codeConsts = platformConsts.codeGraphic; + this.codeGraph?.children[2].position.set(platformConsts.width / 2 + + platformConsts.lineWidth / 2 + + (codeConsts.besideSpacing * 4) / 3, (-platformConsts.height * 10) / 11); + } + this.changeState(); + } + changeState() { + const platformConsts = platformConstsMap.get(this.categoryType); + const states = this.states; + this.doorGraphic?.changeState(states); + this.lozengeGraphic?.changeState(states); + this.codeGraph?.changeState(states, platformConsts); } } class PlatformTemplate extends JlGraphicTemplate { @@ -98,4 +331,4 @@ class PlatformTemplate extends JlGraphicTemplate { } } -export { Platform, PlatformTemplate }; +export { DoorGraphic, Platform, PlatformTemplate }; diff --git a/components/Platform/PlatformConfig.d.ts b/components/Platform/PlatformConfig.d.ts index 369384e..33d9384 100644 --- a/components/Platform/PlatformConfig.d.ts +++ b/components/Platform/PlatformConfig.d.ts @@ -1,23 +1,54 @@ import { GraphicData, GraphicState } from "jl-graphic"; export declare enum CategoryType { - JK = "JK",// 交控(11) - TH = "TH",// 通号(12) - ZDWX = "ZDWX" + BeiJing = "BeiJing",//北京 + XiAn = "XiAn" } export interface PlatformConstsConfig { width: number; height: number; lineWidth: number; - rectColor: string; + grey: string; + yellow: string; + blue: string; doorGraphic?: DoorConstsConfig; + codeGraphic?: CodeConstsConfig; + lozengeGraphic?: LozengeConstsConfig; } export interface DoorConstsConfig { - doorOpenSpacing: number; doorGreen: string; + doorRed: string; + doorBlue: string; + doorOpenSpacing: number; + blueShowColor: string; + doorPlatformSpacing: number; +} +export interface CodeConstsConfig { + circleRadius: number; + besideSpacing: number; + besideFontSize: number; + whiteNumbers: string; + whiteCircle: string; + HCharYellow: string; + HCharWhite: string; + HCharRed: string; +} +export interface LozengeConstsConfig { + lozengeRed?: string; + doorPlatformSpacing: number; } export declare const platformConstsMap: Map; +declare enum TypeOfPlatform { + Unknown = 0, + up = 1, + down = 2 +} export interface IPlatformData extends GraphicData { code: string; + hasdoor?: boolean; + direction?: string; + up?: boolean; + type?: TypeOfPlatform; + centralizedStation?: number; refStation: string; refSection: string; refEsbRelayCode?: string; @@ -25,6 +56,43 @@ export interface IPlatformData extends GraphicData { copyFrom(data: IPlatformData): void; eq(other: IPlatformData): boolean; } -export interface IPlatformState extends GraphicState { +export interface IXiAnPlatformState extends GraphicState { + 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); + get rtuId(): number; + set rtuId(v: number); +} +export interface IBriJingPlatformState extends GraphicState { id?: number; } +export {}; diff --git a/components/Platform/PlatformConfig.js b/components/Platform/PlatformConfig.js index 32c2e6e..16ad449 100644 --- a/components/Platform/PlatformConfig.js +++ b/components/Platform/PlatformConfig.js @@ -1,25 +1,53 @@ var CategoryType; (function (CategoryType) { - CategoryType["JK"] = "JK"; - CategoryType["TH"] = "TH"; - CategoryType["ZDWX"] = "ZDWX"; + CategoryType["BeiJing"] = "BeiJing"; + CategoryType["XiAn"] = "XiAn"; })(CategoryType || (CategoryType = {})); -const jkConsts = { - width: 80, - height: 30, - lineWidth: 3, - rectColor: '0xffffff', -}; -const thConsts = { +const BeiJingConsts = { width: 90, height: 20, lineWidth: 3, - rectColor: '#f00', + grey: '0x7F7F7F', + yellow: '0xfbff00', + blue: '0xC0C0FE', +}; +const XiAnConsts = { + width: 90, + height: 20, + lineWidth: 3, + grey: '0x7F7F7F', + yellow: '0xfbff00', + blue: '0xC0C0FE', + blueShowColor: '0x3149c3', doorGraphic: { + blueShowColor: '0x3149c3', doorOpenSpacing: 15, doorGreen: '0x00FF00', - } + doorRed: '0xff0000', + doorBlue: '0x4048C4', + doorPlatformSpacing: 10, + }, + codeGraphic: { + circleRadius: 1, + besideSpacing: 10, + besideFontSize: 12, + whiteNumbers: '0xffffff', + whiteCircle: '0xffffff', + HCharYellow: '0xfbff00', + HCharWhite: '0xffffff', + HCharRed: '0xff0000', + }, + lozengeGraphic: { + lozengeRed: '0xff0000', + doorPlatformSpacing: 10, + }, }; -const platformConstsMap = new Map([[CategoryType.JK, jkConsts], [CategoryType.TH, thConsts]]); +const platformConstsMap = new Map([[CategoryType.BeiJing, BeiJingConsts], [CategoryType.XiAn, XiAnConsts]]); +var TypeOfPlatform; +(function (TypeOfPlatform) { + TypeOfPlatform[TypeOfPlatform["Unknown"] = 0] = "Unknown"; + TypeOfPlatform[TypeOfPlatform["up"] = 1] = "up"; + TypeOfPlatform[TypeOfPlatform["down"] = 2] = "down"; +})(TypeOfPlatform || (TypeOfPlatform = {})); export { CategoryType, platformConstsMap }; diff --git a/src/packages/Platform/Platform.ts b/src/packages/Platform/Platform.ts index 332dc32..121f105 100644 --- a/src/packages/Platform/Platform.ts +++ b/src/packages/Platform/Platform.ts @@ -1,7 +1,8 @@ -import { GraphicState, JlGraphic, JlGraphicTemplate, distance2, getRectangleCenter } from "jl-graphic"; -import { Container,Graphics,Rectangle,Color } from 'pixi.js' -import {CategoryType, DoorConstsConfig, IPlatformData, IPlatformState, PlatformConstsConfig, platformConstsMap }from './PlatformConfig' +import { JlGraphic, JlGraphicTemplate, VectorText, calculateMirrorPoint, distance2, getRectangleCenter } from "jl-graphic"; +import { Container,Graphics,Rectangle,Color,Point } from 'pixi.js' +import {CategoryType, CodeConstsConfig, DoorConstsConfig, IBriJingPlatformState, IPlatformData, IXiAnPlatformState, LozengeConstsConfig, PlatformConstsConfig, platformConstsMap }from './PlatformConfig' +type IPlatformState=IBriJingPlatformState|IXiAnPlatformState class RectGraphic extends Container { static Type = 'RectPlatForm'; rectGraphic: Graphics; @@ -10,9 +11,18 @@ class RectGraphic extends Container { this.rectGraphic = new Graphics(); this.addChild(this.rectGraphic); } - draw(platformConsts: PlatformConstsConfig): void { + draw(state: IPlatformState,platformConsts: PlatformConstsConfig): void { const rectGraphic = this.rectGraphic; - const fillColor = platformConsts.rectColor; + rectGraphic.clear(); + let fillColor = platformConsts.grey; + /* if(state instanceof IXiAnPlatformState){ + if (state.trainberth) { + fillColor = platformConsts.yellow; + } + if (state.upSkipstop || state.downSkipstop) { + fillColor = platformConsts.blue; + } + } */ rectGraphic .clear() .lineStyle(platformConsts.lineWidth, new Color(fillColor)) @@ -27,7 +37,8 @@ class RectGraphic extends Container { } } -class DoorGraphic extends Container { +//子元素--门 +export class DoorGraphic extends Container { static Type = 'Door'; doorGraphic: Graphics; doorCloseGraphic: Graphics; @@ -38,61 +49,317 @@ class DoorGraphic extends Container { this.addChild(this.doorGraphic); this.addChild(this.doorCloseGraphic); } - draw(platformConsts: PlatformConstsConfig,doorConstsConfig:DoorConstsConfig): void { + draw(stateData: IXiAnPlatformState, ipRtuStusDown: boolean,platformConsts:PlatformConstsConfig): void { + const doorConsts=platformConsts.doorGraphic as DoorConstsConfig const doorGraphic = this.doorGraphic; const doorCloseGraphic = this.doorCloseGraphic; - let lineColor = doorConstsConfig.doorGreen; - doorGraphic.clear() - .lineStyle(platformConsts.lineWidth, new Color(lineColor)) - .moveTo( + doorGraphic.clear(); + doorCloseGraphic.clear(); + let lineColor = doorConsts.doorGreen; + if (ipRtuStusDown) { + lineColor = doorConsts.blueShowColor; + } else if (stateData.psdCut) { + lineColor = doorConsts.doorRed; + } + doorGraphic.lineStyle(platformConsts.lineWidth, new Color(lineColor)); + doorGraphic.moveTo( -platformConsts.width / 2 - platformConsts.lineWidth / 2, 0 - ) - .lineTo(-doorConstsConfig.doorOpenSpacing, 0) - .moveTo(doorConstsConfig.doorOpenSpacing, 0) - .lineTo( + ); + doorGraphic.lineTo(-doorConsts.doorOpenSpacing, 0); + doorGraphic.moveTo(doorConsts.doorOpenSpacing, 0); + doorGraphic.lineTo( platformConsts.width / 2 + platformConsts.lineWidth / 2, 0 ); //屏蔽门闭合 - doorCloseGraphic.clear() - .lineStyle(platformConsts.lineWidth, new Color(lineColor)) - .moveTo(-doorConstsConfig.doorOpenSpacing, 0) - .lineTo(doorConstsConfig.doorOpenSpacing, 0) + doorCloseGraphic.lineStyle(platformConsts.lineWidth, new Color(lineColor)); + doorCloseGraphic.moveTo(-doorConsts.doorOpenSpacing, 0); + doorCloseGraphic.lineTo(doorConsts.doorOpenSpacing, 0); } clear(): void { this.doorGraphic.clear(); this.doorCloseGraphic.clear(); } + changeState(stateData: IXiAnPlatformState): void { + if (stateData.psdOpen) { + this.doorCloseGraphic.visible = false; + } else { + this.doorCloseGraphic.visible = true; + } + } +} +//子元素--字符 +class CodeGraph extends Container { + static Type = 'Code'; + character: VectorText = new VectorText(''); //扣车H + runLevel: VectorText = new VectorText(''); //运行等级 + runTime: VectorText = new VectorText(''); //运行时间 + stopTime: VectorText = new VectorText(''); //停站时间 + circle: Graphics = new Graphics(); + constructor(platformConsts:PlatformConstsConfig) { + super(); + this.addChild(this.character); + this.addChild(this.runLevel); + this.addChild(this.circle); + this.addChild(this.stopTime); + this.addChild(this.runTime); + const codeConsts=platformConsts.codeGraphic as CodeConstsConfig + this.character.setVectorFontSize(codeConsts.besideFontSize); + this.runLevel.setVectorFontSize(codeConsts.besideFontSize); + this.stopTime.setVectorFontSize(codeConsts.besideFontSize); + this.runTime.setVectorFontSize(codeConsts.besideFontSize); + } + draw(platformConsts:PlatformConstsConfig): void { + const codeConsts=platformConsts.codeGraphic as CodeConstsConfig + //扣车 + const character = this.character; + character.text = 'H'; + character.anchor.set(0.5); + character.position.set( + -platformConsts.width / 2 - + platformConsts.lineWidth / 2 - + (codeConsts.besideSpacing * 2) / 3, + (platformConsts.height * 3) / 4 + ); + character.style.fill = codeConsts.whiteNumbers; + const circle = this.circle; + circle.clear(); + circle.lineStyle(0.5, codeConsts.whiteCircle); + circle.drawCircle(0, 0, codeConsts.circleRadius); + circle.position.set( + -platformConsts.width / 2 - + platformConsts.lineWidth / 2 - + (codeConsts.besideSpacing * 4) / 3, + (platformConsts.height * 3) / 5 + ); + //区间运行等级状态 + const runLevel = this.runLevel; + runLevel.anchor.set(0.5); + runLevel.position.set( + platformConsts.width / 2 + + platformConsts.lineWidth / 2 + + 3 * codeConsts.besideSpacing, + -codeConsts.besideSpacing + ); + runLevel.style.fill = codeConsts.whiteNumbers; + //区间运行时间 + const runTime = this.runTime; + runTime.anchor.set(0.5); + runTime.position.set( + platformConsts.width / 2 + + platformConsts.lineWidth / 2 + + codeConsts.besideSpacing, + -codeConsts.besideSpacing + ); + runTime.style.fill = codeConsts.whiteNumbers; + //停站时间 + const stopTime = this.stopTime; + stopTime.anchor.set(0.5); + stopTime.position.set( + platformConsts.width / 2 + + platformConsts.lineWidth / 2 + + codeConsts.besideSpacing, + codeConsts.besideSpacing + ); + stopTime.style.fill = codeConsts.whiteNumbers; + character.visible = false; + circle.visible = false; + runLevel.visible = false; + stopTime.visible = false; + runTime.visible = false; + } + clear(): void { + this.character.destroy(); + } + changeState(stateData: IXiAnPlatformState,platformConsts:PlatformConstsConfig): void { + const codeConsts=platformConsts.codeGraphic as CodeConstsConfig + if ( + stateData.upHold || + stateData.upOccHold || + stateData.downHold || + stateData.downOccHold + ) { + this.character.text = 'H'; + this.character.visible = true; + this.circle.visible = true; + //上行扣车 + if (stateData.upHold) { + this.character.style.fill = codeConsts.HCharYellow; + } + if (stateData.upOccHold) { + this.character.style.fill = codeConsts.HCharWhite; + } + if (stateData.upHold && stateData.upOccHold) { + this.character.style.fill = codeConsts.HCharRed; + } + //下行扣车 + if (stateData.downHold) { + this.character.style.fill = codeConsts.HCharYellow; + } + if (stateData.downOccHold) { + this.character.style.fill = codeConsts.HCharWhite; + } + if (stateData.downHold && stateData.downOccHold) { + this.character.style.fill = codeConsts.HCharRed; + } + } + //运行等级 + if (stateData.nextSectionRunLevel) { + this.runLevel.visible = false; + this.runLevel.text = stateData.nextSectionRunLevel; + } + //运行时间 + if (stateData.nextSectionRunTime) { + this.runTime.visible = true; + this.runTime.text = stateData.nextSectionRunTime; + } + //停站时间 + if (stateData.stopTime) { + this.stopTime.visible = true; + this.stopTime.text = stateData.stopTime; + } + } +} +//子元素--站台旁菱形图标 +class LozengeGraphic extends Container { + static Type = 'lozengeGraphic'; + lozengeGraphic: Graphics; + constructor() { + super(); + this.lozengeGraphic = new Graphics(); + this.addChild(this.lozengeGraphic); + } + draw(platformConsts:PlatformConstsConfig): void { + const LozengeConsts=platformConsts.lozengeGraphic as LozengeConstsConfig + const lozengeGraphic = this.lozengeGraphic; + lozengeGraphic.clear(); + lozengeGraphic.lineStyle(1, new Color(LozengeConsts.lozengeRed)); + lozengeGraphic.beginFill(LozengeConsts.lozengeRed, 1); + lozengeGraphic.drawRect( + 0, + 0, + platformConsts.height / 4, + platformConsts.height / 4 + ); + lozengeGraphic.endFill(); + const rect = new Rectangle( + 0, + 0, + platformConsts.height / 4, + platformConsts.height / 4 + ); + lozengeGraphic.pivot = getRectangleCenter(rect); + lozengeGraphic.rotation = Math.PI / 4; + lozengeGraphic.visible = false; + } + clear(): void { + this.lozengeGraphic.clear(); + } + changeState(stateData: IXiAnPlatformState): void { + if (stateData.emergstop) { + this.lozengeGraphic.visible = true; + } else { + this.lozengeGraphic.visible = false; + } + } } export class Platform extends JlGraphic { static Type = 'Platform'; private categoryType:CategoryType rectGraphic: RectGraphic = new RectGraphic(); - doorGraphic: DoorGraphic = new DoorGraphic(); + doorGraphic?: DoorGraphic; + lozengeGraphic?: LozengeGraphic; + codeGraph?: CodeGraph; constructor(categoryType:CategoryType) { super(Platform.Type); this.categoryType = categoryType this.addChild(this.rectGraphic); - this.addChild(this.doorGraphic); + if(categoryType==CategoryType.XiAn){ + const platformConsts=platformConstsMap.get(this.categoryType) as PlatformConstsConfig + this.doorGraphic = new DoorGraphic() + this.lozengeGraphic = new LozengeGraphic() + this.codeGraph = new CodeGraph(platformConsts) + this.addChild(this.doorGraphic); + this.addChild(this.codeGraph); + this.addChild(this.lozengeGraphic); + } } get datas() { return this.getDatas(); } get states(): IPlatformState { - return this.getStates(); + if(this.categoryType==CategoryType.BeiJing){ + return this.getStates(); + }else{ + return this.getStates(); + } } doRepaint(): void { - this.doorGraphic.clear(); - const platformConsts=platformConstsMap.get(this.categoryType) - if(platformConsts){ - this.rectGraphic.draw(platformConsts); - if(platformConsts.doorGraphic){ - this.doorGraphic.draw(platformConsts,platformConsts.doorGraphic) - } + this.doorGraphic?.clear(); + const platformConsts=platformConstsMap.get(this.categoryType) as PlatformConstsConfig + this.rectGraphic.draw(this.states, platformConsts); + if(this.doorGraphic){ + const states=this.states as IXiAnPlatformState + /* const station = this.getGraphicApp().queryStore.queryByCodeAndType( + states.rtuId > 9 ? '' + states.rtuId : '0' + states.rtuId, + Station.Type + ); */ + this.doorGraphic.draw(states,false,platformConsts) + const doorConsts= platformConsts.doorGraphic as DoorConstsConfig + this.doorGraphic.position.set( + 0, + -platformConsts.height / 2 -doorConsts.doorPlatformSpacing + ); } + if(this.codeGraph){ + this.codeGraph.draw(platformConsts); + this.codeGraph.position.set(0, 0); + } + if(this.lozengeGraphic){ + const LozengeConsts= platformConsts.lozengeGraphic as LozengeConstsConfig + this.lozengeGraphic.draw(platformConsts); + this.lozengeGraphic.position.set( + 0, + -platformConsts.height / 2 - + LozengeConsts.doorPlatformSpacing - + platformConsts.height / 3 + ); + } + + //站台方向 + if (this.datas.direction == 'down') { + const psChange = [ + this.doorGraphic, + this.lozengeGraphic, + this.codeGraph?.children[0], + this.codeGraph?.children[1], + this.codeGraph?.children[3], + this.codeGraph?.children[4], + ]; + psChange.forEach((g) => { + if(g){ + g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position)); + } + }); + const codeConsts=platformConsts.codeGraphic as CodeConstsConfig + this.codeGraph?.children[2].position.set( + platformConsts.width / 2 + + platformConsts.lineWidth / 2 + + (codeConsts.besideSpacing * 4) / 3, + (-platformConsts.height * 10) / 11 + ); + } + this.changeState(); + } + changeState(): void { + const platformConsts=platformConstsMap.get(this.categoryType) as PlatformConstsConfig + const states=this.states as IXiAnPlatformState + this.doorGraphic?.changeState(states); + this.lozengeGraphic?.changeState(states); + this.codeGraph?.changeState(states,platformConsts); } /* buildRelation() { const stationas = this.queryStore.queryByType(Station.Type); diff --git a/src/packages/Platform/PlatformConfig.ts b/src/packages/Platform/PlatformConfig.ts index 7859186..d1592aa 100644 --- a/src/packages/Platform/PlatformConfig.ts +++ b/src/packages/Platform/PlatformConfig.ts @@ -1,56 +1,146 @@ import { GraphicData, GraphicState } from "jl-graphic"; export enum CategoryType { - JK = 'JK', // 交控(11) - TH = 'TH', // 通号(12) - ZDWX = 'ZDWX', // 浙大网新 + BeiJing = 'BeiJing', //北京 + XiAn = 'XiAn', //西安 } export interface PlatformConstsConfig{ width: number, height: number, lineWidth: number, - rectColor: string, //站台颜色 - doorGraphic?:DoorConstsConfig + grey: string, //站台没有列车停站 + yellow :string, //列车在站台停站 + blue : string, //列车在站台跳停 + doorGraphic?:DoorConstsConfig, + codeGraphic?:CodeConstsConfig, + lozengeGraphic?:LozengeConstsConfig //站台旁的菱形图标 } export interface DoorConstsConfig{ - doorOpenSpacing:number, doorGreen:string, + doorRed : string, + doorBlue : string, + doorOpenSpacing:number, + blueShowColor:string + doorPlatformSpacing: number, } -const jkConsts = { - width: 80, - height: 30, - lineWidth: 3, - rectColor: '0xffffff', -}; +export interface CodeConstsConfig{ + circleRadius:number, + besideSpacing:number, + besideFontSize: number, + whiteNumbers : string, //站台旁白色数字 + whiteCircle : string, //H字符旁的圆圈 + HCharYellow: string, //站台旁的H字符 + HCharWhite : string, + HCharRed :string, +} -const thConsts = { +export interface LozengeConstsConfig{ + lozengeRed?:string //站台旁的菱形图标 + doorPlatformSpacing: number, +} + +const BeiJingConsts = { width: 90, height: 20, lineWidth: 3, - rectColor: '#f00', - doorGraphic:{ - doorOpenSpacing: 15, - doorGreen:'0x00FF00', - } + grey: '0x7F7F7F', + yellow :'0xfbff00', + blue : '0xC0C0FE', }; -export const platformConstsMap = new Map([[CategoryType.JK,jkConsts],[CategoryType.TH,thConsts]]) +const XiAnConsts = { + width: 90, + height: 20, + lineWidth: 3, + grey: '0x7F7F7F', + yellow :'0xfbff00', + blue : '0xC0C0FE', + blueShowColor: '0x3149c3', + doorGraphic:{ + blueShowColor: '0x3149c3', + doorOpenSpacing: 15, + doorGreen:'0x00FF00', + doorRed : '0xff0000', + doorBlue : '0x4048C4', + doorPlatformSpacing: 10, + }, + codeGraphic:{ + circleRadius:1, + besideSpacing:10, + besideFontSize:12, + whiteNumbers : '0xffffff', + whiteCircle : '0xffffff', + HCharYellow: '0xfbff00', + HCharWhite : '0xffffff', + HCharRed :'0xff0000', + }, + lozengeGraphic:{ + lozengeRed:'0xff0000', + doorPlatformSpacing: 10, + }, +}; +export const platformConstsMap = new Map([[CategoryType.BeiJing,BeiJingConsts],[CategoryType.XiAn,XiAnConsts]]) + +enum TypeOfPlatform { + Unknown = 0, + up = 1, + down = 2 +} export interface IPlatformData extends GraphicData { code: string; - refStation: string; - refSection: string; - refEsbRelayCode?: string; - /* get type(): graphicData.Platform.TypeOfPlatform; //站台上下行 - set type(v: graphicData.Platform.TypeOfPlatform); */ + hasdoor?:boolean; // 是否有屏蔽门--西安 + direction?: string; // 屏蔽门上下--西安 + up?: boolean; // 站台上下行--西安 + type?:TypeOfPlatform;// 站台上下行--北京 + centralizedStation?: number; //所属集中站--西安 + refStation: string;// 关联的车站 + refSection: string;// 关联的物理区段 + refEsbRelayCode?: string;// 关联的紧急停车继电器的编号--北京 clone(): IPlatformData; copyFrom(data: IPlatformData): void; eq(other: IPlatformData): boolean; } -export interface IPlatformState extends GraphicState { +export interface IXiAnPlatformState extends GraphicState { + 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); + get rtuId(): number; // 集中站站号 + set rtuId(v: number); +} +export interface IBriJingPlatformState extends GraphicState { id?: number; }