This commit is contained in:
fan 2023-12-28 18:07:14 +08:00
commit 9f8bbb232c
8 changed files with 398 additions and 346 deletions

View File

@ -1,22 +1,22 @@
import { JlGraphic, JlGraphicTemplate, VectorText } from "jl-graphic";
import { Container, Graphics } from 'pixi.js';
import { CategoryType, IBriJingPlatformState, IPlatformData, IXiAnPlatformState, PlatformConstsConfig } from './PlatformConfig';
type IPlatformState = IBriJingPlatformState | IXiAnPlatformState;
import { CategoryType, IBeiJingPlatformState, IPlatformData, IXiAnPlatformState, PlatformConstsConfig } from './PlatformConfig';
type IPlatformState = IBeiJingPlatformState | IXiAnPlatformState;
declare class RectGraphic extends Container {
static Type: string;
rectGraphic: Graphics;
constructor();
draw(state: IPlatformState, platformConsts: PlatformConstsConfig): void;
draw(categoryType: CategoryType, stateData: IPlatformState, platformConsts: PlatformConstsConfig): void;
clear(): void;
}
export declare class DoorGraphic extends Container {
declare class DoorGraphic extends Container {
static Type: string;
doorGraphic: Graphics;
doorCloseGraphic: Graphics;
constructor();
draw(stateData: IXiAnPlatformState, ipRtuStusDown: boolean, platformConsts: PlatformConstsConfig): void;
draw(categoryType: CategoryType, stateData: IPlatformState, platformConsts: PlatformConstsConfig, ipRtuStusDown: boolean): void;
clear(): void;
changeState(stateData: IXiAnPlatformState): void;
changeState(categoryType: CategoryType, stateData: IPlatformState): void;
}
declare class CodeGraph extends Container {
static Type: string;
@ -28,7 +28,7 @@ declare class CodeGraph extends Container {
constructor(platformConsts: PlatformConstsConfig);
draw(platformConsts: PlatformConstsConfig): void;
clear(): void;
changeState(stateData: IXiAnPlatformState, platformConsts: PlatformConstsConfig): void;
changeState(categoryType: CategoryType, stateData: IPlatformState, platformConsts: PlatformConstsConfig): void;
}
declare class LozengeGraphic extends Container {
static Type: string;
@ -36,7 +36,7 @@ declare class LozengeGraphic extends Container {
constructor();
draw(platformConsts: PlatformConstsConfig): void;
clear(): void;
changeState(stateData: IXiAnPlatformState): void;
changeState(categoryType: CategoryType, stateData: IPlatformState): void;
}
export declare class Platform extends JlGraphic {
static Type: string;
@ -53,7 +53,7 @@ export declare class Platform extends JlGraphic {
}
export declare class PlatformTemplate extends JlGraphicTemplate<Platform> {
categoryType: CategoryType;
constructor(dataTemplate: IPlatformData, stateTemplate: IPlatformState, gategoryConsts: CategoryType);
constructor(dataTemplate: IPlatformData, stateTemplate: IPlatformState, categoryType: CategoryType);
new(): Platform;
}
export {};

View File

@ -1,27 +1,30 @@
import { JlGraphic, calculateMirrorPoint, JlGraphicTemplate, getRectangleCenter, VectorText } from 'jl-graphic';
import { Container, Graphics, Color, Point, Rectangle } from 'pixi.js';
import { Point, Container, Graphics, Color, Rectangle } from 'pixi.js';
import { platformConstsMap, CategoryType } from './PlatformConfig.js';
//子元素--矩形
class RectGraphic extends Container {
static Type = 'RectPlatForm';
static Type = 'Rect';
rectGraphic;
constructor() {
super();
this.rectGraphic = new Graphics();
this.addChild(this.rectGraphic);
}
draw(state, platformConsts) {
draw(categoryType, stateData, platformConsts) {
const rectGraphic = this.rectGraphic;
rectGraphic.clear();
let fillColor = platformConsts.grey;
/* if(state instanceof IXiAnPlatformState){
if (state.trainberth) {
fillColor = platformConsts.yellow;
}
if (state.upSkipstop || state.downSkipstop) {
fillColor = platformConsts.blue;
}
} */
let fillColor = platformConsts.noTrainStop;
switch (categoryType) {
case CategoryType.XiAn:
const stateXiAn = stateData;
if (stateXiAn.trainberth) {
fillColor = platformConsts.trainStop;
}
if (stateXiAn.upSkipstop || stateXiAn.downSkipstop) {
fillColor = platformConsts.trainJump;
}
break;
}
rectGraphic
.clear()
.lineStyle(platformConsts.lineWidth, new Color(fillColor))
@ -45,16 +48,21 @@ class DoorGraphic extends Container {
this.addChild(this.doorGraphic);
this.addChild(this.doorCloseGraphic);
}
draw(stateData, ipRtuStusDown, platformConsts) {
draw(categoryType, stateData, platformConsts, ipRtuStusDown) {
const doorConsts = platformConsts.doorGraphic;
const doorGraphic = this.doorGraphic;
const doorCloseGraphic = this.doorCloseGraphic;
let lineColor = doorConsts.doorGreen;
if (ipRtuStusDown) {
lineColor = doorConsts.blueShowColor;
}
else if (stateData.psdCut) {
lineColor = doorConsts.doorRed;
switch (categoryType) {
case CategoryType.XiAn:
const stateXiAn = stateData;
if (ipRtuStusDown) {
lineColor = doorConsts.blueShowColor;
}
else if (stateXiAn.psdCut) {
lineColor = doorConsts.doorRed;
}
break;
}
doorGraphic.clear()
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
@ -72,12 +80,17 @@ class DoorGraphic extends Container {
this.doorGraphic.clear();
this.doorCloseGraphic.clear();
}
changeState(stateData) {
if (stateData.psdOpen) {
this.doorCloseGraphic.visible = false;
}
else {
this.doorCloseGraphic.visible = true;
changeState(categoryType, stateData) {
switch (categoryType) {
case CategoryType.XiAn:
const stateXiAn = stateData;
if (stateXiAn.psdOpen) {
this.doorCloseGraphic.visible = false;
}
else {
this.doorCloseGraphic.visible = true;
}
break;
}
}
}
@ -149,50 +162,55 @@ class CodeGraph extends Container {
clear() {
this.character.destroy();
}
changeState(stateData, platformConsts) {
changeState(categoryType, 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;
switch (categoryType) {
case CategoryType.XiAn:
const stateXiAn = stateData;
if (stateXiAn.upHold ||
stateXiAn.upOccHold ||
stateXiAn.downHold ||
stateXiAn.downOccHold) {
this.character.text = 'H';
this.character.visible = true;
this.circle.visible = true;
//上行扣车
if (stateXiAn.upHold) {
this.character.style.fill = codeConsts.HCharYellow;
}
if (stateXiAn.upOccHold) {
this.character.style.fill = codeConsts.HCharWhite;
}
if (stateXiAn.upHold && stateXiAn.upOccHold) {
this.character.style.fill = codeConsts.HCharRed;
}
//下行扣车
if (stateXiAn.downHold) {
this.character.style.fill = codeConsts.HCharYellow;
}
if (stateXiAn.downOccHold) {
this.character.style.fill = codeConsts.HCharWhite;
}
if (stateXiAn.downHold && stateXiAn.downOccHold) {
this.character.style.fill = codeConsts.HCharRed;
}
}
//运行等级
if (stateXiAn.nextSectionRunLevel) {
this.runLevel.visible = false;
this.runLevel.text = stateXiAn.nextSectionRunLevel;
}
//运行时间
if (stateXiAn.nextSectionRunTime) {
this.runTime.visible = true;
this.runTime.text = stateXiAn.nextSectionRunTime;
}
//停站时间
if (stateXiAn.stopTime) {
this.stopTime.visible = true;
this.stopTime.text = stateXiAn.stopTime;
}
break;
}
}
}
@ -221,12 +239,17 @@ class LozengeGraphic extends Container {
clear() {
this.lozengeGraphic.clear();
}
changeState(stateData) {
if (stateData.emergstop) {
this.lozengeGraphic.visible = true;
}
else {
this.lozengeGraphic.visible = false;
changeState(categoryType, stateData) {
switch (categoryType) {
case CategoryType.XiAn:
const stateXiAn = stateData;
if (stateXiAn.emergstop) {
this.lozengeGraphic.visible = true;
}
else {
this.lozengeGraphic.visible = false;
}
break;
}
}
}
@ -240,8 +263,8 @@ class Platform extends JlGraphic {
constructor(categoryType) {
super(Platform.Type);
this.categoryType = categoryType;
this.addChild(this.rectGraphic);
const platformConsts = platformConstsMap.get(this.categoryType);
this.addChild(this.rectGraphic);
if (platformConsts.doorGraphic) {
this.doorGraphic = new DoorGraphic();
this.addChild(this.doorGraphic);
@ -259,47 +282,41 @@ class Platform extends JlGraphic {
return this.getDatas();
}
get states() {
if (this.categoryType == CategoryType.BeiJing) {
return this.getStates();
}
else {
return this.getStates();
}
return this.getStates();
}
doRepaint() {
this.doorGraphic?.clear();
const platformConsts = platformConstsMap.get(this.categoryType);
this.rectGraphic.draw(this.states, platformConsts);
if (this.doorGraphic) {
const states = this.states;
this.rectGraphic.draw(this.categoryType, this.states, platformConsts);
if (this.datas.hasdoor && this.doorGraphic) {
const doorConsts = platformConsts.doorGraphic;
/* const station = this.getGraphicApp().queryStore.queryByCodeAndType<Station>(
states.rtuId > 9 ? '' + states.rtuId : '0' + states.rtuId,
Station.Type
); */
this.doorGraphic.draw(states, false, platformConsts);
const doorConsts = platformConsts.doorGraphic;
this.doorGraphic.draw(this.categoryType, this.states, platformConsts, false);
this.doorGraphic.position.set(0, -platformConsts.height / 2 - doorConsts.doorPlatformSpacing);
if (this.datas.direction == 'down') {
this.doorGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.doorGraphic.position));
}
}
if (this.codeGraph) {
const codeConsts = platformConsts.codeGraphic;
this.codeGraph.draw(platformConsts);
this.codeGraph.position.set(0, 0);
if (this.datas.direction == 'down') {
const psChange = [
this.codeGraph?.children[0],
this.codeGraph?.children[1],
this.codeGraph?.children[3],
this.codeGraph?.children[4],
this.codeGraph?.character,
this.codeGraph?.runLevel,
this.codeGraph?.stopTime,
this.codeGraph?.circle,
];
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 +
this.codeGraph?.runTime.position.set(platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
(codeConsts.besideSpacing * 4) / 3, (-platformConsts.height * 10) / 11);
}
@ -318,17 +335,16 @@ class Platform extends JlGraphic {
}
changeState() {
const platformConsts = platformConstsMap.get(this.categoryType);
const states = this.states;
this.doorGraphic?.changeState(states);
this.lozengeGraphic?.changeState(states);
this.codeGraph?.changeState(states, platformConsts);
this.doorGraphic?.changeState(this.categoryType, this.states);
this.lozengeGraphic?.changeState(this.categoryType, this.states);
this.codeGraph?.changeState(this.categoryType, this.states, platformConsts);
}
}
class PlatformTemplate extends JlGraphicTemplate {
categoryType;
constructor(dataTemplate, stateTemplate, gategoryConsts) {
constructor(dataTemplate, stateTemplate, categoryType) {
super(Platform.Type, { dataTemplate, stateTemplate });
this.categoryType = gategoryConsts;
this.categoryType = categoryType;
}
new() {
const g = new Platform(this.categoryType);
@ -338,4 +354,4 @@ class PlatformTemplate extends JlGraphicTemplate {
}
}
export { DoorGraphic, Platform, PlatformTemplate };
export { Platform, PlatformTemplate };

View File

@ -7,9 +7,9 @@ export interface PlatformConstsConfig {
width: number;
height: number;
lineWidth: number;
grey: string;
yellow: string;
blue: string;
noTrainStop: string;
trainStop: string;
trainJump: string;
doorGraphic?: DoorConstsConfig;
codeGraphic?: CodeConstsConfig;
lozengeGraphic?: LozengeConstsConfig;
@ -49,8 +49,8 @@ export interface IPlatformData extends GraphicData {
up?: boolean;
type?: TypeOfPlatform;
centralizedStation?: number;
refStation: string;
refSection: string;
refStation: number;
refSection: number;
refEsbRelayCode?: string;
clone(): IPlatformData;
copyFrom(data: IPlatformData): void;
@ -92,7 +92,7 @@ export interface IXiAnPlatformState extends GraphicState {
get rtuId(): number;
set rtuId(v: number);
}
export interface IBriJingPlatformState extends GraphicState {
export interface IBeiJingPlatformState extends GraphicState {
id?: number;
}
export {};

View File

@ -7,17 +7,17 @@ const BeiJingConsts = {
width: 90,
height: 20,
lineWidth: 3,
grey: '0x7F7F7F',
yellow: '0xfbff00',
blue: '0xC0C0FE',
noTrainStop: '0xffffff',
trainStop: '0xfbff00',
trainJump: '0xC0C0FE',
};
const XiAnConsts = {
width: 90,
height: 20,
lineWidth: 3,
grey: '0x7F7F7F',
yellow: '0xfbff00',
blue: '0xC0C0FE',
noTrainStop: '0x7F7F7F',
trainStop: '0xfbff00',
trainJump: '0xC0C0FE',
blueShowColor: '0x3149c3',
doorGraphic: {
blueShowColor: '0x3149c3',

View File

@ -0,0 +1,35 @@
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) {
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;
}
}

View File

@ -1,64 +1,53 @@
import { JlGraphic, JlGraphicTemplate, VectorText, calculateMirrorPoint, distance2, getRectangleCenter } from "jl-graphic";
import { JlGraphic, VectorText, calculateMirrorPoint, 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'
import {CategoryType, CodeConstsConfig, DoorConstsConfig, IPlatformData, LozengeConstsConfig, PlatformConstsConfig, platformConstsMap }from './PlatformConfig'
type IPlatformState=IBriJingPlatformState|IXiAnPlatformState
//子元素--矩形
class RectGraphic extends Container {
static Type = 'RectPlatForm';
rectGraphic: Graphics;
constructor() {
categoryType:CategoryType
rect: Graphics;
stateFillColor?:string;
constructor(categoryType:CategoryType) {
super();
this.rectGraphic = new Graphics();
this.addChild(this.rectGraphic);
this.categoryType=categoryType
this.rect = new Graphics();
this.addChild(this.rect);
}
draw(state: IPlatformState,platformConsts: PlatformConstsConfig): void {
const rectGraphic = this.rectGraphic;
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
draw(platformConsts: PlatformConstsConfig): void {
const rect = this.rect;
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;
rectGraphic.pivot = getRectangleCenter(
rect.pivot = getRectangleCenter(
new Rectangle(0, 0, platformConsts.width, platformConsts.height)
);
}
clear(): void {
this.rectGraphic.clear();
this.rect.clear();
}
}
//子元素--门
export class DoorGraphic extends Container {
static Type = 'Door';
class DoorGraphic extends Container {
categoryType:CategoryType
doorGraphic: Graphics;
doorCloseGraphic: Graphics;
constructor() {
stateFillColor?:string;
constructor(categoryType:CategoryType) {
super();
this.categoryType=categoryType
this.doorGraphic = new Graphics();
this.doorCloseGraphic = new Graphics();
this.addChild(this.doorGraphic);
this.addChild(this.doorCloseGraphic);
}
draw(stateData: IXiAnPlatformState, ipRtuStusDown: boolean,platformConsts:PlatformConstsConfig): void {
draw(platformConsts:PlatformConstsConfig): void {
const doorConsts=platformConsts.doorGraphic as DoorConstsConfig
const doorGraphic = this.doorGraphic;
const doorCloseGraphic = this.doorCloseGraphic;
let lineColor = doorConsts.doorGreen;
if (ipRtuStusDown) {
lineColor = doorConsts.blueShowColor;
} else if (stateData.psdCut) {
lineColor = doorConsts.doorRed;
}
const lineColor = this.stateFillColor ||doorConsts.doorGreen;
doorGraphic.clear()
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(
@ -81,24 +70,18 @@ export class DoorGraphic extends Container {
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';
class CodeGraphic extends Container {
categoryType:CategoryType
character: VectorText = new VectorText(''); //扣车H
runLevel: VectorText = new VectorText(''); //运行等级
runTime: VectorText = new VectorText(''); //运行时间
stopTime: VectorText = new VectorText(''); //停站时间
circle: Graphics = new Graphics();
constructor(platformConsts:PlatformConstsConfig) {
constructor(categoryType:CategoryType,platformConsts:PlatformConstsConfig) {
super();
this.categoryType=categoryType
this.addChild(this.character);
this.addChild(this.runLevel);
this.addChild(this.circle);
@ -172,68 +155,21 @@ class CodeGraph extends Container {
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() {
categoryType:CategoryType
lozenge: Graphics;
constructor(categoryType:CategoryType) {
super();
this.lozengeGraphic = new Graphics();
this.addChild(this.lozengeGraphic);
this.categoryType=categoryType
this.lozenge = new Graphics();
this.addChild(this.lozenge);
}
draw(platformConsts:PlatformConstsConfig): void {
const LozengeConsts=platformConsts.lozengeGraphic as LozengeConstsConfig
const lozengeGraphic = this.lozengeGraphic;
lozengeGraphic.clear()
const lozenge = this.lozenge;
lozenge.clear()
.lineStyle(1, new Color(LozengeConsts.lozengeRed))
.beginFill(LozengeConsts.lozengeRed, 1)
.drawRect(
@ -249,69 +185,51 @@ class LozengeGraphic extends Container {
platformConsts.height / 4,
platformConsts.height / 4
);
lozengeGraphic.pivot = getRectangleCenter(rect);
lozengeGraphic.rotation = Math.PI / 4;
lozengeGraphic.visible = false;
lozenge.pivot = getRectangleCenter(rect);
lozenge.rotation = Math.PI / 4;
lozenge.visible = false;
}
clear(): void {
this.lozengeGraphic.clear();
}
changeState(stateData: IXiAnPlatformState): void {
if (stateData.emergstop) {
this.lozengeGraphic.visible = true;
} else {
this.lozengeGraphic.visible = false;
}
this.lozenge.clear();
}
}
export class Platform extends JlGraphic {
export abstract class JlPlatform extends JlGraphic {
static Type = 'Platform';
private categoryType:CategoryType
rectGraphic: RectGraphic = new RectGraphic();
rectGraphic: RectGraphic;
doorGraphic?: DoorGraphic;
lozengeGraphic?: LozengeGraphic;
codeGraph?: CodeGraph;
codeGraphic?: CodeGraphic;
constructor(categoryType:CategoryType) {
super(Platform.Type);
super(JlPlatform.Type);
this.categoryType = categoryType
this.addChild(this.rectGraphic);
const platformConsts=platformConstsMap.get(this.categoryType) as PlatformConstsConfig
this.rectGraphic = new RectGraphic(categoryType)
this.addChild(this.rectGraphic);
if(platformConsts.doorGraphic){
this.doorGraphic = new DoorGraphic()
this.doorGraphic = new DoorGraphic(categoryType)
this.addChild(this.doorGraphic);
}
if(platformConsts.lozengeGraphic){
this.lozengeGraphic = new LozengeGraphic()
this.lozengeGraphic = new LozengeGraphic(categoryType)
this.addChild(this.lozengeGraphic);
}
if(platformConsts.codeGraphic){
this.codeGraph = new CodeGraph(platformConsts)
this.addChild(this.codeGraph);
this.codeGraphic = new CodeGraphic(categoryType,platformConsts)
this.addChild(this.codeGraphic);
}
}
get datas() {
return this.getDatas<IPlatformData>();
}
get states(): IPlatformState {
if(this.categoryType==CategoryType.BeiJing){
return this.getStates<IBriJingPlatformState>();
}else{
return this.getStates<IXiAnPlatformState>();
}
}
doRepaint(): void {
this.doorGraphic?.clear();
const platformConsts=platformConstsMap.get(this.categoryType) as PlatformConstsConfig
this.rectGraphic.draw(this.states, platformConsts);
this.rectGraphic.draw(platformConsts);
if(this.doorGraphic){
const states=this.states as IXiAnPlatformState
/* const station = this.getGraphicApp().queryStore.queryByCodeAndType<Station>(
states.rtuId > 9 ? '' + states.rtuId : '0' + states.rtuId,
Station.Type
); */
this.doorGraphic.draw(states,false,platformConsts)
const doorConsts= platformConsts.doorGraphic as DoorConstsConfig
this.doorGraphic.draw(platformConsts)
this.doorGraphic.position.set(
0,
-platformConsts.height / 2 -doorConsts.doorPlatformSpacing
@ -320,23 +238,23 @@ export class Platform extends JlGraphic {
this.doorGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.doorGraphic.position))
}
}
if(this.codeGraph){
this.codeGraph.draw(platformConsts);
this.codeGraph.position.set(0, 0);
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.codeGraph?.children[0],
this.codeGraph?.children[1],
this.codeGraph?.children[3],
this.codeGraph?.children[4],
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));
}
});
const codeConsts=platformConsts.codeGraphic as CodeConstsConfig
this.codeGraph?.children[2].position.set(
this.codeGraphic?.circle.position.set(
platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
(codeConsts.besideSpacing * 4) / 3,
@ -357,30 +275,5 @@ export class Platform extends JlGraphic {
this.lozengeGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.lozengeGraphic.position))
}
}
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);
}
}
export class PlatformTemplate extends JlGraphicTemplate<Platform> {
categoryType:CategoryType;
constructor(
dataTemplate: IPlatformData,
stateTemplate: IPlatformState,
gategoryConsts: CategoryType
) {
super(Platform.Type, { dataTemplate, stateTemplate });
this.categoryType = gategoryConsts;
}
new(): Platform {
const g = new Platform(this.categoryType);
g.loadData(this.datas);
g.loadState(this.states);
return g;
}
}

View File

@ -9,9 +9,9 @@ export interface PlatformConstsConfig{
width: number,
height: number,
lineWidth: number,
grey: string, //站台没有列车停站
yellow :string, //列车在站台停站
blue : string, //列车在站台跳停
noTrainStop: string, //站台没有列车停站
trainStop :string, //列车在站台停站
trainJump : string, //列车在站台跳停
doorGraphic?:DoorConstsConfig,
codeGraphic?:CodeConstsConfig,
lozengeGraphic?:LozengeConstsConfig //站台旁的菱形图标
@ -22,49 +22,46 @@ export interface DoorConstsConfig{
doorRed : string,
doorBlue : string,
doorOpenSpacing:number,
blueShowColor:string
doorPlatformSpacing: number,
}
export interface CodeConstsConfig{
circleRadius:number,
besideSpacing:number,
besideFontSize: number,
whiteNumbers : string, //站台旁白色数字
whiteCircle : string, //H字符旁的圆圈
circleRadius:number,
HCharYellow: string, //站台旁的H字符
HCharWhite : string,
HCharRed :string,
}
export interface LozengeConstsConfig{
lozengeRed?:string //站台旁的菱形图标
lozengeRed:string //站台旁的菱形图标
doorPlatformSpacing: number,
}
const BeiJingConsts = {
export const BeiJingConsts = {
width: 90,
height: 20,
lineWidth: 3,
grey: '0x7F7F7F',
yellow :'0xfbff00',
blue : '0xC0C0FE',
noTrainStop: '0xffffff',
trainStop :'0xfbff00',
trainJump : '0xC0C0FE',
};
const XiAnConsts = {
export const XiAnConsts = {
width: 90,
height: 20,
lineWidth: 3,
grey: '0x7F7F7F',
yellow :'0xfbff00',
blue : '0xC0C0FE',
blueShowColor: '0x3149c3',
noTrainStop: '0x7F7F7F',
trainStop :'0xfbff00',
trainJump : '0xC0C0FE',
doorGraphic:{
blueShowColor: '0x3149c3',
doorOpenSpacing: 15,
doorGreen:'0x00FF00',
doorRed : '0xff0000',
doorBlue : '0x4048C4',
doorBlue : '0x3149c3',
doorPlatformSpacing: 10,
},
codeGraphic:{
@ -97,50 +94,10 @@ export interface IPlatformData extends GraphicData {
up?: boolean; // 站台上下行--西安
type?:TypeOfPlatform;// 站台上下行--北京
centralizedStation?: number; //所属集中站--西安
refStation: string;// 关联的车站
refSection: string;// 关联的物理区段
refStation: number;// 关联的车站
refSection: number;// 关联的物理区段
refEsbRelayCode?: string;// 关联的紧急停车继电器的编号--北京
clone(): IPlatformData;
copyFrom(data: IPlatformData): void;
eq(other: IPlatformData): boolean;
}
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;
}

View File

@ -0,0 +1,151 @@
import { GraphicState, JlGraphicTemplate } from "jl-graphic";
import { CategoryType,IPlatformData, XiAnConsts }from './PlatformConfig'
import { JlPlatform } from "./JlPlatform";
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 class XiAnPlatform extends JlPlatform {
constructor(categoryType:CategoryType) {
super(categoryType);
}
get states(): IXiAnPlatformState {
return this.getStates<IXiAnPlatformState>();
}
doRepaint(): void {
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>(
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.doorBlue;
} */ if (this.states.psdCut) {
this.doorGraphic.stateFillColor = XiAnConsts.doorGraphic.doorRed;
}
}
super.doRepaint()
if (this.doorGraphic) {
if (this.states.psdOpen) {
this.doorGraphic.doorCloseGraphic.visible = false;
} else {
this.doorGraphic.doorCloseGraphic.visible = true;
}
}
if( this.lozengeGraphic){
if (this.states.emergstop) {
this.lozengeGraphic.lozenge.visible = true;
} else {
this.lozengeGraphic.lozenge.visible = false;
}
}
if(this.codeGraphic){
if (
this.states.upHold ||
this.states.upOccHold ||
this.states.downHold ||
this.states.downOccHold
) {
this.codeGraphic.character.text = 'H';
this.codeGraphic.character.visible = true;
this.codeGraphic.circle.visible = true;
//上行扣车
if (this.states.upHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharYellow;
}
if (this.states.upOccHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharWhite;
}
if (this.states.upHold && this.states.upOccHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharRed;
}
//下行扣车
if (this.states.downHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharYellow;
}
if (this.states.downOccHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharWhite;
}
if (this.states.downHold && this.states.downOccHold) {
this.codeGraphic.character.style.fill = XiAnConsts.codeGraphic.HCharRed;
}
}
//运行等级
if (this.states.nextSectionRunLevel) {
this.codeGraphic.runLevel.visible = false;
this.codeGraphic.runLevel.text = this.states.nextSectionRunLevel;
}
//运行时间
if (this.states.nextSectionRunTime) {
this.codeGraphic.runTime.visible = true;
this.codeGraphic.runTime.text = this.states.nextSectionRunTime;
}
//停站时间
if (this.states.stopTime) {
this.codeGraphic.stopTime.visible = true;
this.codeGraphic.stopTime.text = this.states.stopTime;
}
}
}
}
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;
}
}