车站基类备用

This commit is contained in:
joylink_zhaoerwei 2023-12-29 16:45:44 +08:00
parent 9f8bbb232c
commit 66e28a8c68
6 changed files with 554 additions and 210 deletions

View File

@ -1,35 +1,20 @@
import { GraphicState, JlGraphicTemplate } from "jl-graphic";
import { CategoryType,IPlatformData, BeiJingConsts }from './PlatformConfig'
import { JlPlatform } from "./JlPlatform";
import { GraphicState, JlGraphicTemplate } from 'jl-graphic';
import { CategoryType, IPlatformData, BeiJingConsts } from './PlatformConfig';
import { JlPlatform } from './JlPlatform';
export interface IBeiJingPlatformState extends GraphicState {
id?: number;
}
export class BeiJingPlatform extends JlPlatform {
constructor(categoryType:CategoryType) {
constructor(categoryType: CategoryType) {
super(categoryType);
}
get states(): IBeiJingPlatformState {
return this.getStates<IBeiJingPlatformState>();
}
doRepaint(): void {
this.rectGraphic.stateFillColor=BeiJingConsts.noTrainStop
super.doRepaint()
}
}
export class BeiJingPlatformTemplate extends JlGraphicTemplate<BeiJingPlatform> {
constructor(
dataTemplate: IPlatformData,
stateTemplate: IBeiJingPlatformState,
) {
super(BeiJingPlatform.Type, { dataTemplate, stateTemplate });
}
new(): BeiJingPlatform {
const g = new BeiJingPlatform(CategoryType.BeiJing);
g.loadData(this.datas);
g.loadState(this.states);
return g;
this.rectGraphic.stateFillColor = BeiJingConsts.noTrainStop;
super.doRepaint();
}
}

View File

@ -1,28 +1,44 @@
import { JlGraphic, VectorText, calculateMirrorPoint, getRectangleCenter } from "jl-graphic";
import { Container,Graphics,Rectangle,Color,Point } from 'pixi.js'
import {CategoryType, CodeConstsConfig, DoorConstsConfig, IPlatformData, LozengeConstsConfig, PlatformConstsConfig, platformConstsMap }from './PlatformConfig'
import {
JlGraphic,
JlGraphicTemplate,
VectorText,
calculateMirrorPoint,
getRectangleCenter,
} from 'jl-graphic';
import { Container, Graphics, Rectangle, Color, Point } from 'pixi.js';
import {
CategoryType,
CodeConstsConfig,
DoorConstsConfig,
IPlatformData,
LozengeConstsConfig,
PlatformConstsConfig,
platformConstsMap,
} from './PlatformConfig';
import { IXiAnPlatformState, XiAnPlatform } from './XiAnPlatform';
import { BeiJingPlatform, IBeiJingPlatformState } from './BeiJingPlatform';
//子元素--矩形
class RectGraphic extends Container {
categoryType:CategoryType
categoryType: CategoryType;
rect: Graphics;
stateFillColor?:string;
constructor(categoryType:CategoryType) {
stateFillColor?: string;
constructor(categoryType: CategoryType) {
super();
this.categoryType=categoryType
this.categoryType = categoryType;
this.rect = new Graphics();
this.addChild(this.rect);
}
draw(platformConsts: PlatformConstsConfig): void {
const rect = this.rect;
const fillColor = this.stateFillColor ||platformConsts.noTrainStop;
const fillColor = this.stateFillColor || platformConsts.noTrainStop;
rect
.clear()
.lineStyle(platformConsts.lineWidth, new Color(fillColor))
.beginFill(fillColor, 1)
.drawRect(0, 0, platformConsts.width, platformConsts.height).endFill;
rect.pivot = getRectangleCenter(
new Rectangle(0, 0, platformConsts.width, platformConsts.height)
rect.pivot = getRectangleCenter(
new Rectangle(0, 0, platformConsts.width, platformConsts.height),
);
}
clear(): void {
@ -31,40 +47,36 @@ class RectGraphic extends Container {
}
//子元素--门
class DoorGraphic extends Container {
categoryType:CategoryType
categoryType: CategoryType;
doorGraphic: Graphics;
doorCloseGraphic: Graphics;
stateFillColor?:string;
constructor(categoryType:CategoryType) {
stateFillColor?: string;
constructor(categoryType: CategoryType) {
super();
this.categoryType=categoryType
this.categoryType = categoryType;
this.doorGraphic = new Graphics();
this.doorCloseGraphic = new Graphics();
this.addChild(this.doorGraphic);
this.addChild(this.doorCloseGraphic);
}
draw(platformConsts:PlatformConstsConfig): void {
const doorConsts=platformConsts.doorGraphic as DoorConstsConfig
draw(platformConsts: PlatformConstsConfig): void {
const doorConsts = platformConsts.doorGraphic as DoorConstsConfig;
const doorGraphic = this.doorGraphic;
const doorCloseGraphic = this.doorCloseGraphic;
const lineColor = this.stateFillColor ||doorConsts.doorGreen;
doorGraphic.clear()
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(
-platformConsts.width / 2 - platformConsts.lineWidth / 2,
0
)
.lineTo(-doorConsts.doorOpenSpacing, 0)
.moveTo(doorConsts.doorOpenSpacing, 0)
.lineTo(
platformConsts.width / 2 + platformConsts.lineWidth / 2,
0
)
const lineColor = this.stateFillColor || doorConsts.doorGreen;
doorGraphic
.clear()
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(-platformConsts.width / 2 - platformConsts.lineWidth / 2, 0)
.lineTo(-doorConsts.doorOpenSpacing, 0)
.moveTo(doorConsts.doorOpenSpacing, 0)
.lineTo(platformConsts.width / 2 + platformConsts.lineWidth / 2, 0);
//屏蔽门闭合
doorCloseGraphic.clear()
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(-doorConsts.doorOpenSpacing, 0)
.lineTo(doorConsts.doorOpenSpacing, 0);
doorCloseGraphic
.clear()
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(-doorConsts.doorOpenSpacing, 0)
.lineTo(doorConsts.doorOpenSpacing, 0);
}
clear(): void {
this.doorGraphic.clear();
@ -73,28 +85,31 @@ class DoorGraphic extends Container {
}
//子元素--字符
class CodeGraphic extends Container {
categoryType:CategoryType
categoryType: CategoryType;
character: VectorText = new VectorText(''); //扣车H
runLevel: VectorText = new VectorText(''); //运行等级
runTime: VectorText = new VectorText(''); //运行时间
stopTime: VectorText = new VectorText(''); //停站时间
circle: Graphics = new Graphics();
constructor(categoryType:CategoryType,platformConsts:PlatformConstsConfig) {
constructor(
categoryType: CategoryType,
platformConsts: PlatformConstsConfig,
) {
super();
this.categoryType=categoryType
this.categoryType = categoryType;
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
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
draw(platformConsts: PlatformConstsConfig): void {
const codeConsts = platformConsts.codeGraphic as CodeConstsConfig;
//扣车
const character = this.character;
character.text = 'H';
@ -103,18 +118,19 @@ class CodeGraphic extends Container {
-platformConsts.width / 2 -
platformConsts.lineWidth / 2 -
(codeConsts.besideSpacing * 2) / 3,
(platformConsts.height * 3) / 4
(platformConsts.height * 3) / 4,
);
character.style.fill = codeConsts.whiteNumbers;
const circle = this.circle;
circle.clear()
.lineStyle(0.5, codeConsts.whiteCircle)
.drawCircle(0, 0, codeConsts.circleRadius)
circle
.clear()
.lineStyle(0.5, codeConsts.whiteCircle)
.drawCircle(0, 0, codeConsts.circleRadius);
circle.position.set(
-platformConsts.width / 2 -
platformConsts.lineWidth / 2 -
(codeConsts.besideSpacing * 4) / 3,
(platformConsts.height * 3) / 5
(platformConsts.height * 3) / 5,
);
//区间运行等级状态
const runLevel = this.runLevel;
@ -123,7 +139,7 @@ class CodeGraphic extends Container {
platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
3 * codeConsts.besideSpacing,
-codeConsts.besideSpacing
-codeConsts.besideSpacing,
);
runLevel.style.fill = codeConsts.whiteNumbers;
//区间运行时间
@ -133,7 +149,7 @@ class CodeGraphic extends Container {
platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
codeConsts.besideSpacing,
-codeConsts.besideSpacing
-codeConsts.besideSpacing,
);
runTime.style.fill = codeConsts.whiteNumbers;
//停站时间
@ -143,7 +159,7 @@ class CodeGraphic extends Container {
platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
codeConsts.besideSpacing,
codeConsts.besideSpacing
codeConsts.besideSpacing,
);
stopTime.style.fill = codeConsts.whiteNumbers;
character.visible = false;
@ -158,32 +174,28 @@ class CodeGraphic extends Container {
}
//子元素--站台旁菱形图标
class LozengeGraphic extends Container {
categoryType:CategoryType
categoryType: CategoryType;
lozenge: Graphics;
constructor(categoryType:CategoryType) {
constructor(categoryType: CategoryType) {
super();
this.categoryType=categoryType
this.categoryType = categoryType;
this.lozenge = new Graphics();
this.addChild(this.lozenge);
}
draw(platformConsts:PlatformConstsConfig): void {
const LozengeConsts=platformConsts.lozengeGraphic as LozengeConstsConfig
draw(platformConsts: PlatformConstsConfig): void {
const LozengeConsts = platformConsts.lozengeGraphic as LozengeConstsConfig;
const lozenge = this.lozenge;
lozenge.clear()
.lineStyle(1, new Color(LozengeConsts.lozengeRed))
.beginFill(LozengeConsts.lozengeRed, 1)
.drawRect(
0,
0,
platformConsts.height / 4,
platformConsts.height / 4
)
.endFill();
lozenge
.clear()
.lineStyle(1, new Color(LozengeConsts.lozengeRed))
.beginFill(LozengeConsts.lozengeRed, 1)
.drawRect(0, 0, platformConsts.height / 4, platformConsts.height / 4)
.endFill();
const rect = new Rectangle(
0,
0,
platformConsts.height / 4,
platformConsts.height / 4
platformConsts.height / 4,
);
lozenge.pivot = getRectangleCenter(rect);
lozenge.rotation = Math.PI / 4;
@ -196,27 +208,30 @@ class LozengeGraphic extends Container {
export abstract class JlPlatform extends JlGraphic {
static Type = 'Platform';
private categoryType:CategoryType
private categoryType: CategoryType;
private platformConsts: PlatformConstsConfig;
rectGraphic: RectGraphic;
doorGraphic?: DoorGraphic;
lozengeGraphic?: LozengeGraphic;
codeGraphic?: CodeGraphic;
constructor(categoryType:CategoryType) {
constructor(categoryType: CategoryType) {
super(JlPlatform.Type);
this.categoryType = categoryType
const platformConsts=platformConstsMap.get(this.categoryType) as PlatformConstsConfig
this.rectGraphic = new RectGraphic(categoryType)
this.categoryType = categoryType;
this.platformConsts = platformConstsMap.get(
this.categoryType,
) as PlatformConstsConfig;
this.rectGraphic = new RectGraphic(categoryType);
this.addChild(this.rectGraphic);
if(platformConsts.doorGraphic){
this.doorGraphic = new DoorGraphic(categoryType)
if (this.platformConsts.doorGraphic) {
this.doorGraphic = new DoorGraphic(categoryType);
this.addChild(this.doorGraphic);
}
if(platformConsts.lozengeGraphic){
this.lozengeGraphic = new LozengeGraphic(categoryType)
if (this.platformConsts.lozengeGraphic) {
this.lozengeGraphic = new LozengeGraphic(categoryType);
this.addChild(this.lozengeGraphic);
}
if(platformConsts.codeGraphic){
this.codeGraphic = new CodeGraphic(categoryType,platformConsts)
if (this.platformConsts.codeGraphic) {
this.codeGraphic = new CodeGraphic(categoryType, this.platformConsts);
this.addChild(this.codeGraphic);
}
}
@ -225,55 +240,96 @@ export abstract class JlPlatform extends JlGraphic {
}
doRepaint(): void {
this.doorGraphic?.clear();
const platformConsts=platformConstsMap.get(this.categoryType) as PlatformConstsConfig
const platformConsts = this.platformConsts;
this.rectGraphic.draw(platformConsts);
if(this.doorGraphic){
const doorConsts= platformConsts.doorGraphic as DoorConstsConfig
this.doorGraphic.draw(platformConsts)
if (this.doorGraphic) {
const doorConsts = platformConsts.doorGraphic as DoorConstsConfig;
this.doorGraphic.draw(platformConsts);
this.doorGraphic.position.set(
0,
-platformConsts.height / 2 -doorConsts.doorPlatformSpacing
-platformConsts.height / 2 - doorConsts.doorPlatformSpacing,
);
if (this.datas.direction == 'down') {
this.doorGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.doorGraphic.position))
this.doorGraphic.position.copyFrom(
calculateMirrorPoint(new Point(0, 0), this.doorGraphic.position),
);
}
}
if(this.codeGraphic){
const codeConsts=platformConsts.codeGraphic as CodeConstsConfig
if (this.codeGraphic) {
const codeConsts = platformConsts.codeGraphic as CodeConstsConfig;
this.codeGraphic.draw(platformConsts);
this.codeGraphic.position.set(0, 0);
if (this.datas.direction == 'down') {
const psChange = [
this.codeGraphic?.character,
this.codeGraphic?.runLevel,
this.codeGraphic?.stopTime,
this.codeGraphic?.runTime,
this.codeGraphic.character,
this.codeGraphic.runLevel,
this.codeGraphic.stopTime,
this.codeGraphic.runTime,
];
psChange.forEach((g) => {
if(g){
g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position));
if (g) {
g.position.copyFrom(
calculateMirrorPoint(new Point(0, 0), g.position),
);
}
});
this.codeGraphic?.circle.position.set(
this.codeGraphic.circle.position.set(
platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
(codeConsts.besideSpacing * 4) / 3,
(-platformConsts.height * 10) / 11
(-platformConsts.height * 10) / 11,
);
}
}
if(this.lozengeGraphic){
const LozengeConsts= platformConsts.lozengeGraphic as LozengeConstsConfig
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
LozengeConsts.doorPlatformSpacing -
platformConsts.height / 3,
);
if (this.datas.direction == 'down') {
this.lozengeGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.lozengeGraphic.position))
this.lozengeGraphic.position.copyFrom(
calculateMirrorPoint(new Point(0, 0), this.lozengeGraphic.position),
);
}
}
}
}
export class PlatformTemplate extends JlGraphicTemplate<JlPlatform> {
hasdoor?: boolean;
direction?: string;
categoryType: CategoryType;
constructor(
dataTemplate: IPlatformData,
stateTemplate: IXiAnPlatformState | IBeiJingPlatformState,
categoryType: CategoryType,
) {
super(JlPlatform.Type, { dataTemplate, stateTemplate });
this.categoryType = categoryType;
switch (this.categoryType) {
case CategoryType.XiAn:
this.hasdoor = true;
this.direction = 'up';
break;
}
}
new(): JlPlatform {
switch (this.categoryType) {
case CategoryType.BeiJing:
const BeiJing = new BeiJingPlatform(CategoryType.BeiJing);
BeiJing.loadData(this.datas);
BeiJing.loadState(this.states);
return BeiJing;
default:
const XiAn = new XiAnPlatform(CategoryType.XiAn);
XiAn.loadData(this.datas);
XiAn.loadState(this.states);
return XiAn;
}
}
}

View File

@ -1,44 +1,44 @@
import { GraphicData, GraphicState } from "jl-graphic";
import { GraphicData } from 'jl-graphic';
export enum CategoryType {
BeiJing = 'BeiJing', //北京
XiAn = 'XiAn', //西安
}
export interface PlatformConstsConfig{
width: number,
height: number,
lineWidth: number,
noTrainStop: string, //站台没有列车停站
trainStop :string, //列车在站台停站
trainJump : string, //列车在站台跳停
doorGraphic?:DoorConstsConfig,
codeGraphic?:CodeConstsConfig,
lozengeGraphic?:LozengeConstsConfig //站台旁的菱形图标
export interface PlatformConstsConfig {
width: number;
height: number;
lineWidth: number;
noTrainStop: string; //站台没有列车停站
trainStop: string; //列车在站台停站
trainJump: string; //列车在站台跳停
doorGraphic?: DoorConstsConfig;
codeGraphic?: CodeConstsConfig;
lozengeGraphic?: LozengeConstsConfig; //站台旁的菱形图标
}
export interface DoorConstsConfig{
doorGreen:string,
doorRed : string,
doorBlue : string,
doorOpenSpacing:number,
doorPlatformSpacing: number,
export interface DoorConstsConfig {
doorGreen: string;
doorRed: string;
doorBlue: string;
doorOpenSpacing: number;
doorPlatformSpacing: number;
}
export interface CodeConstsConfig{
besideSpacing:number,
besideFontSize: number,
whiteNumbers : string, //站台旁白色数字
whiteCircle : string, //H字符旁的圆圈
circleRadius:number,
HCharYellow: string, //站台旁的H字符
HCharWhite : string,
HCharRed :string,
export interface CodeConstsConfig {
besideSpacing: number;
besideFontSize: number;
whiteNumbers: string; //站台旁白色数字
whiteCircle: string; //H字符旁的圆圈
circleRadius: number;
HCharYellow: string; //站台旁的H字符
HCharWhite: string;
HCharRed: string;
}
export interface LozengeConstsConfig{
lozengeRed:string //站台旁的菱形图标
doorPlatformSpacing: number,
export interface LozengeConstsConfig {
lozengeRed: string; //站台旁的菱形图标
doorPlatformSpacing: number;
}
export const BeiJingConsts = {
@ -46,8 +46,8 @@ export const BeiJingConsts = {
height: 20,
lineWidth: 3,
noTrainStop: '0xffffff',
trainStop :'0xfbff00',
trainJump : '0xC0C0FE',
trainStop: '0xfbff00',
trainJump: '0xC0C0FE',
};
export const XiAnConsts = {
@ -55,48 +55,51 @@ export const XiAnConsts = {
height: 20,
lineWidth: 3,
noTrainStop: '0x7F7F7F',
trainStop :'0xfbff00',
trainJump : '0xC0C0FE',
doorGraphic:{
trainStop: '0xfbff00',
trainJump: '0xC0C0FE',
doorGraphic: {
doorOpenSpacing: 15,
doorGreen:'0x00FF00',
doorRed : '0xff0000',
doorBlue : '0x3149c3',
doorGreen: '0x00FF00',
doorRed: '0xff0000',
doorBlue: '0x3149c3',
doorPlatformSpacing: 10,
},
codeGraphic:{
circleRadius:1,
besideSpacing:10,
besideFontSize:12,
whiteNumbers : '0xffffff',
whiteCircle : '0xffffff',
codeGraphic: {
circleRadius: 1,
besideSpacing: 10,
besideFontSize: 12,
whiteNumbers: '0xffffff',
whiteCircle: '0xffffff',
HCharYellow: '0xfbff00',
HCharWhite : '0xffffff',
HCharRed :'0xff0000',
HCharWhite: '0xffffff',
HCharRed: '0xff0000',
},
lozengeGraphic:{
lozengeRed:'0xff0000',
lozengeGraphic: {
lozengeRed: '0xff0000',
doorPlatformSpacing: 10,
},
};
export const platformConstsMap = new Map<CategoryType, PlatformConstsConfig>([[CategoryType.BeiJing,BeiJingConsts],[CategoryType.XiAn,XiAnConsts]])
export const platformConstsMap = new Map<CategoryType, PlatformConstsConfig>([
[CategoryType.BeiJing, BeiJingConsts],
[CategoryType.XiAn, XiAnConsts],
]);
enum TypeOfPlatform {
Unknown = 0,
up = 1,
down = 2
down = 2,
}
export interface IPlatformData extends GraphicData {
code: string;
hasdoor?:boolean; // 是否有屏蔽门--西安
direction?: string; // 屏蔽门上下--西安
up?: boolean; // 站台上下行--西安
type?:TypeOfPlatform;// 站台上下行--北京
centralizedStation?: number; //所属集中站--西安
refStation: number;// 关联的车站
refSection: number;// 关联的物理区段
refEsbRelayCode?: string;// 关联的紧急停车继电器的编号--北京
code: string;
hasdoor?: boolean; // 是否有屏蔽门--西安
direction?: string; // 屏蔽门上下--西安
up?: boolean; // 站台上下行--西安
type?: TypeOfPlatform; // 站台上下行--北京
centralizedStation?: number; //所属集中站--西安
refStation: number; // 关联的车站
refSection: number; // 关联的物理区段
refEsbRelayCode?: string; // 关联的紧急停车继电器的编号--北京
clone(): IPlatformData;
copyFrom(data: IPlatformData): void;
eq(other: IPlatformData): boolean;

View File

@ -1,6 +1,6 @@
import { GraphicState, JlGraphicTemplate } from "jl-graphic";
import { CategoryType,IPlatformData, XiAnConsts }from './PlatformConfig'
import { JlPlatform } from "./JlPlatform";
import { GraphicState, JlGraphicTemplate } from 'jl-graphic';
import { CategoryType, IPlatformData, XiAnConsts } from './PlatformConfig';
import { JlPlatform } from './JlPlatform';
export interface IXiAnPlatformState extends GraphicState {
get emergstop(): boolean; //紧急关闭
@ -40,33 +40,33 @@ export interface IXiAnPlatformState extends GraphicState {
}
export class XiAnPlatform extends JlPlatform {
constructor(categoryType:CategoryType) {
constructor(categoryType: CategoryType) {
super(categoryType);
}
get states(): IXiAnPlatformState {
return this.getStates<IXiAnPlatformState>();
}
doRepaint(): void {
this.rectGraphic.stateFillColor=XiAnConsts.noTrainStop
this.rectGraphic.stateFillColor = XiAnConsts.noTrainStop;
if (this.states.trainberth) {
this.rectGraphic.stateFillColor = XiAnConsts.trainStop;
}
if (this.states.upSkipstop || this.states.downSkipstop) {
this.rectGraphic.stateFillColor = XiAnConsts.trainJump;
}
/* const station = this.getGraphicApp().queryStore.queryByCodeAndType<Station>(
/* const station = this.getGraphicApp().queryStore.queryByCodeAndType<Station>(
this.states.rtuId > 9 ? '' + this.states.rtuId : '0' + this.states.rtuId,
Station.Type
); */
if (this.doorGraphic) {
this.doorGraphic.stateFillColor=XiAnConsts.doorGraphic.doorGreen
/* if (!!station?.states.ipRtuStusDown) {
this.doorGraphic.stateFillColor = XiAnConsts.doorGraphic.doorGreen;
/* if (!!station?.states.ipRtuStusDown) {
this.doorGraphic.stateFillColor = XiAnConsts.doorGraphic.doorBlue;
} */ if (this.states.psdCut) {
this.doorGraphic.stateFillColor = XiAnConsts.doorGraphic.doorRed;
}
}
super.doRepaint()
super.doRepaint();
if (this.doorGraphic) {
if (this.states.psdOpen) {
this.doorGraphic.doorCloseGraphic.visible = false;
@ -74,14 +74,14 @@ export class XiAnPlatform extends JlPlatform {
this.doorGraphic.doorCloseGraphic.visible = true;
}
}
if( this.lozengeGraphic){
if (this.lozengeGraphic) {
if (this.states.emergstop) {
this.lozengeGraphic.lozenge.visible = true;
} else {
this.lozengeGraphic.lozenge.visible = false;
}
}
if(this.codeGraphic){
if (this.codeGraphic) {
if (
this.states.upHold ||
this.states.upOccHold ||
@ -93,23 +93,29 @@ export class XiAnPlatform extends JlPlatform {
this.codeGraphic.circle.visible = true;
//上行扣车
if (this.states.upHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharYellow;
this.codeGraphic.character.style.fill =
XiAnConsts.codeGraphic.HCharYellow;
}
if (this.states.upOccHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharWhite;
this.codeGraphic.character.style.fill =
XiAnConsts.codeGraphic.HCharWhite;
}
if (this.states.upHold && this.states.upOccHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharRed;
this.codeGraphic.character.style.fill =
XiAnConsts.codeGraphic.HCharRed;
}
//下行扣车
if (this.states.downHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharYellow;
this.codeGraphic.character.style.fill =
XiAnConsts.codeGraphic.HCharYellow;
}
if (this.states.downOccHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharWhite;
this.codeGraphic.character.style.fill =
XiAnConsts.codeGraphic.HCharWhite;
}
if (this.states.downHold && this.states.downOccHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharRed;
this.codeGraphic.character.style.fill =
XiAnConsts.codeGraphic.HCharRed;
}
}
//运行等级
@ -130,22 +136,3 @@ export class XiAnPlatform extends JlPlatform {
}
}
}
export class XiAnPlatformTemplate extends JlGraphicTemplate<XiAnPlatform> {
hasdoor: boolean;
direction: string;
constructor(
dataTemplate: IPlatformData,
stateTemplate: IXiAnPlatformState,
) {
super(XiAnPlatform.Type, { dataTemplate, stateTemplate });
this.hasdoor = true;
this.direction = 'up';
}
new(): XiAnPlatform {
const g = new XiAnPlatform(CategoryType.XiAn);
g.loadData(this.datas);
g.loadState(this.states);
return g;
}
}

View File

@ -0,0 +1,173 @@
import { Color, Container, Graphics, Point } from 'pixi.js';
import { JlGraphic, VectorText } from 'jl-graphic';
import {
ConstrolConstsConfig,
ConstrolItemConfig,
IStationData,
StationConstsConfig,
stationConstsMap,
} from './StationConfig';
import { CategoryType } from '../Platform/PlatformConfig';
class constrolGraphic extends Container {
categoryType: CategoryType;
constrolConfig?: ConstrolItemConfig[];
stateArrowFillColor?: string;
constructor(categoryType: CategoryType) {
super();
this.categoryType = categoryType;
}
draw(stationConsts: StationConstsConfig): void {
const constrolConsts =
stationConsts.constrolGraphic as ConstrolConstsConfig;
const graphicsPs: { circlePs: Point; codeGraphPs: Point }[] = [];
for (let i = 0; i < constrolConsts.constrolConfig.length; i++) {
const posX =
constrolConsts.circleBetweenOffset *
(i - (constrolConsts.constrolConfig.length - 1) / 2);
graphicsPs.push({
circlePs: new Point(posX, constrolConsts.circleOffsetY),
codeGraphPs: new Point(posX, constrolConsts.codeOffsetY),
});
}
const constrolConfig = this.constrolConfig || constrolConsts.constrolConfig;
constrolConfig.forEach((g, i) => {
this.drawCircleCode(
constrolConsts,
g.codeText,
g.circleFillColor,
g.codeGraphFillColor,
graphicsPs[i],
);
});
if (constrolConsts.inArrowFillColor) {
const points = [0, 0, 2, 2, 2, 1, 14, 1, 14, -1, 2, -1, 2, -2];
const arrow = new Graphics();
arrow
.clear()
.lineStyle(constrolConsts.borderWidth, new Color('0xFFFFFF'))
.beginFill('0xFFFFFF')
.drawPolygon(points)
.endFill();
arrow.scale.set(1.1, 1.1);
arrow.position.set(-7, constrolConsts.circleOffsetY);
this.addChild(arrow);
const inArrow = new Graphics();
const fillColor =
this.stateArrowFillColor || constrolConsts.inArrowFillColor;
inArrow.beginFill(fillColor).drawPolygon(points).endFill();
inArrow.position.set(-6.5, constrolConsts.circleOffsetY);
this.addChild(inArrow);
}
}
drawCircleCode(
constrolConsts: ConstrolConstsConfig,
code: string,
circleFillColor: string,
codeGraphFillColor: string,
pos: { circlePs: Point; codeGraphPs: Point },
): void {
const circle = new Graphics();
const codeGraph = new VectorText();
this.addChild(circle);
this.addChild(codeGraph);
circle.tint = 0xffffff;
circle
.clear()
.lineStyle(constrolConsts.borderWidth, new Color(circleFillColor))
.beginFill(circleFillColor, 1)
.drawCircle(0, 0, constrolConsts.radius).endFill;
circle.position.copyFrom(pos.circlePs as Point);
codeGraph.text = code;
codeGraph.style.fill = codeGraphFillColor;
codeGraph.setVectorFontSize(constrolConsts.codeControlFontSize);
codeGraph.anchor.set(0.5);
codeGraph.position.copyFrom(pos.codeGraphPs as Point);
}
clear(): void {
this.children.forEach((child) => {
if (child instanceof Graphics) {
child.clear();
} else if (child instanceof VectorText) {
child.text = '';
}
});
}
}
export class JlStation extends JlGraphic {
static Type = 'station';
private categoryType: CategoryType;
stationConsts: StationConstsConfig;
codeGraph: VectorText = new VectorText(''); //车站名
kilometerGraph: VectorText = new VectorText(''); //公里标
controlGraphic?: constrolGraphic;
_ipRtuStusDown = false;
constructor(categoryType: CategoryType) {
super(JlStation.Type);
this.categoryType = categoryType;
this.stationConsts = stationConstsMap.get(
this.categoryType,
) as StationConstsConfig;
this.addChild(this.codeGraph);
this.addChild(this.kilometerGraph);
if (this.stationConsts.constrolGraphic) {
this.controlGraphic = new constrolGraphic(categoryType);
this.addChild(this.controlGraphic);
}
}
get datas(): IStationData {
return this.getDatas<IStationData>();
}
get code(): string {
return this.datas.code;
}
doRepaint(): void {
const codeGraph = this.codeGraph;
const kilometerGraph = this.kilometerGraph;
const controlGraphic = this.controlGraphic;
controlGraphic?.clear();
switch (this.categoryType) {
case CategoryType.XiAn:
codeGraph.text = this.datas?.code
? `${this.datas?.name}(${this.datas?.code})`
: `${this.datas?.name}`;
break;
case CategoryType.BeiJing:
codeGraph.text = this.datas?.code || '车站Station';
break;
}
codeGraph.style.fill = this.stationConsts.codeColor;
codeGraph.setVectorFontSize(this.stationConsts.codeFontSize);
codeGraph.anchor.set(0.5);
const kilometerCode = this.datas.kilometerSystem?.kilometer || 12345678;
if (Math.floor(kilometerCode * 1000).toString().length > 3) {
const kiloBit = Math.floor(Number(kilometerCode) / 1000000).toString();
kilometerGraph.text =
'K' +
kiloBit +
'+' +
(
Number(kilometerCode.toString().substring(kiloBit.length)) / 1000
).toFixed(3);
} else {
kilometerGraph.text = (kilometerCode * 1000).toFixed(3);
}
kilometerGraph.style.fill = this.stationConsts.kilometerCodeColor;
kilometerGraph.setVectorFontSize(this.stationConsts.kilometerCodeFontSize);
kilometerGraph.anchor.set(0.5);
kilometerGraph.position.set(0, this.stationConsts.kilometerCodeOffsetY);
if (this.datas.childTransforms?.length) {
this.datas.childTransforms.forEach((child) => {
if (child.name == 'kilometer') {
const pos = child.transform.position;
kilometerGraph.position.set(pos.x, pos.y);
}
});
}
if (this.controlGraphic) {
this.controlGraphic.draw(this.stationConsts);
}
}
}

View File

@ -0,0 +1,140 @@
import { GraphicData } from 'jl-graphic';
import { CategoryType } from '../Platform/PlatformConfig';
export interface StationConstsConfig {
codeColor: string;
codeFontSize: number;
kilometerCodeColor: string;
kilometerCodeFontSize: number;
kilometerCodeOffsetY: number;
constrolGraphic?: ConstrolConstsConfig;
}
export interface ConstrolConstsConfig {
radius: number;
borderWidth: number;
codeControlFontSize: number;
codeOffsetY: number;
circleOffsetY: number;
circleBetweenOffset: number;
constrolConfig: ConstrolItemConfig[];
inArrowFillColor?: string;
}
export interface ConstrolItemConfig {
codeText: string;
circleFillColor: string;
codeGraphFillColor: string;
}
export const BeiJingConsts = {
codeColor: '0xF48815',
codeFontSize: 22,
kilometerCodeColor: '0xFFFFFF',
kilometerCodeFontSize: 8,
kilometerCodeOffsetY: -25,
};
export const XiAnConsts = {
codeColor: '0xF48815',
codeFontSize: 22,
kilometerCodeColor: '0xFFFFFF',
kilometerCodeFontSize: 8,
kilometerCodeOffsetY: -25,
constrolGraphic: {
radius: 3,
borderWidth: 1,
codeControlFontSize: 12,
codeOffsetY: 30,
circleOffsetY: 20,
circleBetweenOffset: 40,
inArrowFillColor: '0x808080',
constrolConfig: [
{
codeText: '中控',
circleFillColor: '0x08F80D',
codeGraphFillColor: '0x08F80D',
},
{
codeText: '站控',
circleFillColor: '0x808080',
codeGraphFillColor: '0xFFFFFF',
},
],
},
};
export const otherConsts = {
codeColor: '0xF48815',
codeFontSize: 22,
kilometerCodeColor: '0xFFFFFF',
kilometerCodeFontSize: 8,
kilometerCodeOffsetY: -25,
constrolGraphic: {
radius: 3,
borderWidth: 1,
codeControlFontSize: 12,
codeOffsetY: 30,
circleOffsetY: 20,
circleBetweenOffset: 40,
constrolConfig: [
{
codeText: '紧急站控',
circleFillColor: '0x808080',
codeGraphFillColor: '0xFFFFFF',
},
{
codeText: '中控',
circleFillColor: '0x08F80D',
codeGraphFillColor: '0x08F80D',
},
{
codeText: '站控',
circleFillColor: '0x808080',
codeGraphFillColor: '0xFFFFFF',
},
{
codeText: '联锁控',
circleFillColor: '0x808080',
codeGraphFillColor: '0xFFFFFF',
},
{
codeText: '按图折返',
circleFillColor: '0xFFFA0C',
codeGraphFillColor: '0xFFFA0C',
},
],
},
};
export const stationConstsMap = new Map<CategoryType, StationConstsConfig>([
[CategoryType.BeiJing, BeiJingConsts],
[CategoryType.XiAn, XiAnConsts],
]);
export interface IStationData extends GraphicData {
code: string; // 车站索引
kilometerSystem: KilometerSystem;
hasControl: boolean; //是否有控制
concentrationStations: boolean; //是否集中站
name: string; //车站名称
manageStations: number[]; //集中站管理的车站
depots: boolean; //是否车辆段
clone(): IStationData;
copyFrom(data: IStationData): void;
eq(other: IStationData): boolean;
}
export interface KilometerSystem {
get coordinateSystem(): string;
set coordinateSystem(v: string);
get kilometer(): number;
set kilometer(v: number);
get direction(): Direction;
set direction(v: Direction);
}
export enum Direction {
LEFT = 0,
RIGHT = 1,
}