车站子类测试
This commit is contained in:
parent
023058ebb0
commit
574bce4b31
14
components/Platform/PlatformDrawAssistant.d.ts
vendored
14
components/Platform/PlatformDrawAssistant.d.ts
vendored
@ -1,11 +1,8 @@
|
|||||||
import { FederatedPointerEvent, Point } from 'pixi.js';
|
import { FederatedPointerEvent, Point } from 'pixi.js';
|
||||||
import { GraphicDrawAssistant, GraphicInteractionPlugin, IDrawApp, JlGraphic } from 'jl-graphic';
|
import { GraphicDrawAssistant, IDrawApp } from 'jl-graphic';
|
||||||
import { JlPlatform } from './JlPlatform';
|
import { JlPlatform } from './JlPlatform';
|
||||||
import { PlatformTemplate } from './PlatformTemplate';
|
import { PlatformTemplate } from './PlatformTemplate';
|
||||||
import { IPlatformData } from './PlatformConfig';
|
import { IPlatformData } from './PlatformConfig';
|
||||||
export interface IPlatformDrawOptions {
|
|
||||||
newData: () => IPlatformData;
|
|
||||||
}
|
|
||||||
export declare class PlatformDraw extends GraphicDrawAssistant<PlatformTemplate, IPlatformData> {
|
export declare class PlatformDraw extends GraphicDrawAssistant<PlatformTemplate, IPlatformData> {
|
||||||
platformGraphic: JlPlatform;
|
platformGraphic: JlPlatform;
|
||||||
constructor(app: IDrawApp, template: PlatformTemplate, icon: string);
|
constructor(app: IDrawApp, template: PlatformTemplate, icon: string);
|
||||||
@ -14,12 +11,3 @@ export declare class PlatformDraw extends GraphicDrawAssistant<PlatformTemplate,
|
|||||||
redraw(p: Point): void;
|
redraw(p: Point): void;
|
||||||
prepareData(data: IPlatformData): boolean;
|
prepareData(data: IPlatformData): boolean;
|
||||||
}
|
}
|
||||||
export declare class platformInteraction extends GraphicInteractionPlugin<JlPlatform> {
|
|
||||||
static Name: string;
|
|
||||||
constructor(app: IDrawApp);
|
|
||||||
static init(app: IDrawApp): platformInteraction;
|
|
||||||
filter(...grahpics: JlGraphic[]): JlPlatform[] | undefined;
|
|
||||||
bind(g: JlPlatform): void;
|
|
||||||
unbind(g: JlPlatform): void;
|
|
||||||
onSelected(): void;
|
|
||||||
}
|
|
||||||
|
@ -8,7 +8,7 @@ class PlatformDraw extends GraphicDrawAssistant {
|
|||||||
super(app, template, icon, '站台Platform');
|
super(app, template, icon, '站台Platform');
|
||||||
this.platformGraphic = this.graphicTemplate.new();
|
this.platformGraphic = this.graphicTemplate.new();
|
||||||
this.container.addChild(this.platformGraphic);
|
this.container.addChild(this.platformGraphic);
|
||||||
platformInteraction.init(app);
|
PlatformInteraction.init(app);
|
||||||
}
|
}
|
||||||
bind() {
|
bind() {
|
||||||
super.bind();
|
super.bind();
|
||||||
@ -49,13 +49,13 @@ function buildAbsorbablePositions(platform) {
|
|||||||
});
|
});
|
||||||
return aps;
|
return aps;
|
||||||
}
|
}
|
||||||
class platformInteraction extends GraphicInteractionPlugin {
|
class PlatformInteraction extends GraphicInteractionPlugin {
|
||||||
static Name = 'platform_transform';
|
static Name = 'platform_transform';
|
||||||
constructor(app) {
|
constructor(app) {
|
||||||
super(platformInteraction.Name, app);
|
super(PlatformInteraction.Name, app);
|
||||||
}
|
}
|
||||||
static init(app) {
|
static init(app) {
|
||||||
return new platformInteraction(app);
|
return new PlatformInteraction(app);
|
||||||
}
|
}
|
||||||
filter(...grahpics) {
|
filter(...grahpics) {
|
||||||
return grahpics
|
return grahpics
|
||||||
@ -83,4 +83,4 @@ class platformInteraction extends GraphicInteractionPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { PlatformDraw, platformInteraction };
|
export { PlatformDraw };
|
||||||
|
10
components/Station/BeiJingStation.d.ts
vendored
Normal file
10
components/Station/BeiJingStation.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { GraphicState } from 'jl-graphic';
|
||||||
|
import { JlStation } from './JlStation';
|
||||||
|
export interface IBeiJingStationState extends GraphicState {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
export declare class BeiJingStation extends JlStation {
|
||||||
|
constructor();
|
||||||
|
get states(): IBeiJingStationState;
|
||||||
|
doRepaint(): void;
|
||||||
|
}
|
16
components/Station/BeiJingStation.js
Normal file
16
components/Station/BeiJingStation.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { JlStation } from './JlStation.js';
|
||||||
|
import { CategoryType } from '../Platform/PlatformConfig.js';
|
||||||
|
|
||||||
|
class BeiJingStation extends JlStation {
|
||||||
|
constructor() {
|
||||||
|
super(CategoryType.BeiJing);
|
||||||
|
}
|
||||||
|
get states() {
|
||||||
|
return this.getStates();
|
||||||
|
}
|
||||||
|
doRepaint() {
|
||||||
|
super.doRepaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { BeiJingStation };
|
5
components/Station/JlStation.d.ts
vendored
5
components/Station/JlStation.d.ts
vendored
@ -14,14 +14,13 @@ declare class ConstrolGraphic extends Container {
|
|||||||
}): void;
|
}): void;
|
||||||
clear(): void;
|
clear(): void;
|
||||||
}
|
}
|
||||||
export declare class JlStation extends JlGraphic {
|
export declare abstract class JlStation extends JlGraphic {
|
||||||
static Type: string;
|
static Type: string;
|
||||||
private categoryType;
|
private categoryType;
|
||||||
stationConsts: StationConstsConfig;
|
private stationConsts;
|
||||||
codeGraph: VectorText;
|
codeGraph: VectorText;
|
||||||
kilometerGraph: VectorText;
|
kilometerGraph: VectorText;
|
||||||
controlGraphic?: ConstrolGraphic;
|
controlGraphic?: ConstrolGraphic;
|
||||||
_ipRtuStusDown: boolean;
|
|
||||||
constructor(categoryType: CategoryType);
|
constructor(categoryType: CategoryType);
|
||||||
get datas(): IStationData;
|
get datas(): IStationData;
|
||||||
get code(): string;
|
get code(): string;
|
||||||
|
@ -26,7 +26,7 @@ class ConstrolGraphic extends Container {
|
|||||||
constrolConfig.forEach((g, i) => {
|
constrolConfig.forEach((g, i) => {
|
||||||
this.drawCircleCode(constrolConsts, g.codeText, g.circleFillColor, g.codeGraphFillColor, graphicsPs[i]);
|
this.drawCircleCode(constrolConsts, g.codeText, g.circleFillColor, g.codeGraphFillColor, graphicsPs[i]);
|
||||||
});
|
});
|
||||||
if (constrolConsts.inArrowFillColor) {
|
if (constrolConsts.inArrowConfig) {
|
||||||
const points = [0, 0, 2, 2, 2, 1, 14, 1, 14, -1, 2, -1, 2, -2];
|
const points = [0, 0, 2, 2, 2, 1, 14, 1, 14, -1, 2, -1, 2, -2];
|
||||||
const arrow = new Graphics();
|
const arrow = new Graphics();
|
||||||
arrow
|
arrow
|
||||||
@ -39,7 +39,8 @@ class ConstrolGraphic extends Container {
|
|||||||
arrow.position.set(-7, constrolConsts.circleOffsetY);
|
arrow.position.set(-7, constrolConsts.circleOffsetY);
|
||||||
this.addChild(arrow);
|
this.addChild(arrow);
|
||||||
const inArrow = new Graphics();
|
const inArrow = new Graphics();
|
||||||
const fillColor = this.stateArrowFillColor || constrolConsts.inArrowFillColor;
|
const fillColor = this.stateArrowFillColor ||
|
||||||
|
constrolConsts.inArrowConfig.inArrowFillColorGray;
|
||||||
inArrow.beginFill(fillColor).drawPolygon(points).endFill();
|
inArrow.beginFill(fillColor).drawPolygon(points).endFill();
|
||||||
inArrow.position.set(-6.5, constrolConsts.circleOffsetY);
|
inArrow.position.set(-6.5, constrolConsts.circleOffsetY);
|
||||||
this.addChild(inArrow);
|
this.addChild(inArrow);
|
||||||
@ -81,7 +82,6 @@ class JlStation extends JlGraphic {
|
|||||||
codeGraph = new VectorText(''); //车站名
|
codeGraph = new VectorText(''); //车站名
|
||||||
kilometerGraph = new VectorText(''); //公里标
|
kilometerGraph = new VectorText(''); //公里标
|
||||||
controlGraphic;
|
controlGraphic;
|
||||||
_ipRtuStusDown = false;
|
|
||||||
constructor(categoryType) {
|
constructor(categoryType) {
|
||||||
super(JlStation.Type);
|
super(JlStation.Type);
|
||||||
this.categoryType = categoryType;
|
this.categoryType = categoryType;
|
||||||
|
15
components/Station/StationConfig.d.ts
vendored
15
components/Station/StationConfig.d.ts
vendored
@ -16,13 +16,17 @@ export interface ConstrolConstsConfig {
|
|||||||
circleOffsetY: number;
|
circleOffsetY: number;
|
||||||
circleBetweenOffset: number;
|
circleBetweenOffset: number;
|
||||||
constrolConfig: ConstrolItemConfig[];
|
constrolConfig: ConstrolItemConfig[];
|
||||||
inArrowFillColor?: string;
|
inArrowConfig?: InArrowConfig;
|
||||||
}
|
}
|
||||||
export interface ConstrolItemConfig {
|
export interface ConstrolItemConfig {
|
||||||
codeText: string;
|
codeText: string;
|
||||||
circleFillColor: string;
|
circleFillColor: string;
|
||||||
codeGraphFillColor: string;
|
codeGraphFillColor: string;
|
||||||
}
|
}
|
||||||
|
export interface InArrowConfig {
|
||||||
|
inArrowFillColorGray: string;
|
||||||
|
inArrowFillColorBlue: string;
|
||||||
|
}
|
||||||
export declare const BeiJingConsts: {
|
export declare const BeiJingConsts: {
|
||||||
codeColor: string;
|
codeColor: string;
|
||||||
codeFontSize: number;
|
codeFontSize: number;
|
||||||
@ -43,12 +47,15 @@ export declare const XiAnConsts: {
|
|||||||
codeOffsetY: number;
|
codeOffsetY: number;
|
||||||
circleOffsetY: number;
|
circleOffsetY: number;
|
||||||
circleBetweenOffset: number;
|
circleBetweenOffset: number;
|
||||||
inArrowFillColor: string;
|
|
||||||
constrolConfig: {
|
constrolConfig: {
|
||||||
codeText: string;
|
codeText: string;
|
||||||
circleFillColor: string;
|
circleFillColor: string;
|
||||||
codeGraphFillColor: string;
|
codeGraphFillColor: string;
|
||||||
}[];
|
}[];
|
||||||
|
inArrowConfig: {
|
||||||
|
inArrowFillColorGray: string;
|
||||||
|
inArrowFillColorBlue: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
export declare const otherConsts: {
|
export declare const otherConsts: {
|
||||||
@ -74,12 +81,14 @@ export declare const otherConsts: {
|
|||||||
export declare const stationConstsMap: Map<CategoryType, StationConstsConfig>;
|
export declare const stationConstsMap: Map<CategoryType, StationConstsConfig>;
|
||||||
export interface IStationData extends GraphicData {
|
export interface IStationData extends GraphicData {
|
||||||
code: string;
|
code: string;
|
||||||
|
stationName: string;
|
||||||
kilometerSystem: KilometerSystem;
|
kilometerSystem: KilometerSystem;
|
||||||
hasControl: boolean;
|
hasControl?: boolean;
|
||||||
concentrationStations: boolean;
|
concentrationStations: boolean;
|
||||||
name: string;
|
name: string;
|
||||||
manageStations: number[];
|
manageStations: number[];
|
||||||
depots: boolean;
|
depots: boolean;
|
||||||
|
refIbpMapCode?: string;
|
||||||
clone(): IStationData;
|
clone(): IStationData;
|
||||||
copyFrom(data: IStationData): void;
|
copyFrom(data: IStationData): void;
|
||||||
eq(other: IStationData): boolean;
|
eq(other: IStationData): boolean;
|
||||||
|
@ -20,7 +20,6 @@ const XiAnConsts = {
|
|||||||
codeOffsetY: 30,
|
codeOffsetY: 30,
|
||||||
circleOffsetY: 20,
|
circleOffsetY: 20,
|
||||||
circleBetweenOffset: 40,
|
circleBetweenOffset: 40,
|
||||||
inArrowFillColor: '0x808080',
|
|
||||||
constrolConfig: [
|
constrolConfig: [
|
||||||
{
|
{
|
||||||
codeText: '中控',
|
codeText: '中控',
|
||||||
@ -33,6 +32,10 @@ const XiAnConsts = {
|
|||||||
codeGraphFillColor: '0xFFFFFF',
|
codeGraphFillColor: '0xFFFFFF',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
inArrowConfig: {
|
||||||
|
inArrowFillColorGray: '0x808080',
|
||||||
|
inArrowFillColorBlue: '0x08F80D',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const otherConsts = {
|
const otherConsts = {
|
||||||
|
22
components/Station/StationDrawAssistant.d.ts
vendored
Normal file
22
components/Station/StationDrawAssistant.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { FederatedPointerEvent, Point } from 'pixi.js';
|
||||||
|
import { GraphicDrawAssistant, GraphicInteractionPlugin, IDrawApp, JlGraphic } from 'jl-graphic';
|
||||||
|
import { JlStation } from './JlStation';
|
||||||
|
import { IStationData } from './StationConfig';
|
||||||
|
import { StationTemplate } from './StationTemplate';
|
||||||
|
export declare class StationDraw extends GraphicDrawAssistant<StationTemplate, IStationData> {
|
||||||
|
codeGraph: JlStation;
|
||||||
|
constructor(app: IDrawApp, template: StationTemplate, icon: string);
|
||||||
|
bind(): void;
|
||||||
|
onLeftDown(e: FederatedPointerEvent): void;
|
||||||
|
redraw(p: Point): void;
|
||||||
|
prepareData(data: IStationData): boolean;
|
||||||
|
}
|
||||||
|
export declare class StationInteraction extends GraphicInteractionPlugin<JlStation> {
|
||||||
|
static Name: string;
|
||||||
|
constructor(app: IDrawApp);
|
||||||
|
static init(app: IDrawApp): StationInteraction;
|
||||||
|
filter(...grahpics: JlGraphic[]): JlStation[] | undefined;
|
||||||
|
bind(g: JlStation): void;
|
||||||
|
unbind(g: JlStation): void;
|
||||||
|
onSelected(): void;
|
||||||
|
}
|
84
components/Station/StationDrawAssistant.js
Normal file
84
components/Station/StationDrawAssistant.js
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
import { GraphicDrawAssistant, GraphicInteractionPlugin, AbsorbableLine } from 'jl-graphic';
|
||||||
|
import { JlStation } from './JlStation.js';
|
||||||
|
import { CategoryType } from '../Platform/PlatformConfig.js';
|
||||||
|
|
||||||
|
class StationDraw extends GraphicDrawAssistant {
|
||||||
|
codeGraph;
|
||||||
|
constructor(app, template, icon) {
|
||||||
|
super(app, template, icon, '车站Station');
|
||||||
|
this.codeGraph = this.graphicTemplate.new();
|
||||||
|
this.container.addChild(this.codeGraph);
|
||||||
|
StationInteraction.init(app);
|
||||||
|
}
|
||||||
|
bind() {
|
||||||
|
super.bind();
|
||||||
|
this.codeGraph.loadData(this.graphicTemplate.datas);
|
||||||
|
this.codeGraph.doRepaint();
|
||||||
|
}
|
||||||
|
onLeftDown(e) {
|
||||||
|
this.container.position.copyFrom(this.toCanvasCoordinates(e.global));
|
||||||
|
this.createAndStore(true);
|
||||||
|
}
|
||||||
|
redraw(p) {
|
||||||
|
this.container.position.copyFrom(p);
|
||||||
|
}
|
||||||
|
prepareData(data) {
|
||||||
|
const template = this.graphicTemplate;
|
||||||
|
switch (template.categoryType) {
|
||||||
|
case CategoryType.XiAn:
|
||||||
|
data.hasControl = this.graphicTemplate.hasControl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
data.transform = this.container.saveTransform();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function buildAbsorbablePositions(station) {
|
||||||
|
const aps = [];
|
||||||
|
const stations = station.queryStore.queryByType(JlStation.Type);
|
||||||
|
const { width } = station.getGraphicApp().canvas;
|
||||||
|
stations.forEach((other) => {
|
||||||
|
if (other.id == station.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ps = other.datas.transform.position;
|
||||||
|
const xs = new AbsorbableLine({ x: 0, y: ps.y }, { x: width, y: ps.y });
|
||||||
|
aps.push(xs);
|
||||||
|
});
|
||||||
|
return aps;
|
||||||
|
}
|
||||||
|
class StationInteraction extends GraphicInteractionPlugin {
|
||||||
|
static Name = 'station_transform';
|
||||||
|
constructor(app) {
|
||||||
|
super(StationInteraction.Name, app);
|
||||||
|
}
|
||||||
|
static init(app) {
|
||||||
|
return new StationInteraction(app);
|
||||||
|
}
|
||||||
|
filter(...grahpics) {
|
||||||
|
return grahpics
|
||||||
|
.filter((g) => g.type === JlStation.Type)
|
||||||
|
.map((g) => g);
|
||||||
|
}
|
||||||
|
bind(g) {
|
||||||
|
g.eventMode = 'static';
|
||||||
|
g.cursor = 'pointer';
|
||||||
|
g.scalable = true;
|
||||||
|
g.rotatable = true;
|
||||||
|
g.on('selected', this.onSelected, this);
|
||||||
|
}
|
||||||
|
unbind(g) {
|
||||||
|
g.eventMode = 'none';
|
||||||
|
g.scalable = false;
|
||||||
|
g.rotatable = false;
|
||||||
|
g.off('selected', this.onSelected, this);
|
||||||
|
}
|
||||||
|
onSelected() {
|
||||||
|
const station = this.app.selectedGraphics[0];
|
||||||
|
this.app.setOptions({
|
||||||
|
absorbablePositions: buildAbsorbablePositions(station),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { StationDraw, StationInteraction };
|
12
components/Station/StationTemplate.d.ts
vendored
Normal file
12
components/Station/StationTemplate.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { JlGraphicTemplate } from 'jl-graphic';
|
||||||
|
import { JlStation } from './JlStation';
|
||||||
|
import { IStationData } from './StationConfig';
|
||||||
|
import { IXiAnStationState } from './XiAnStation';
|
||||||
|
import { IBeiJingStationState } from './BeiJingStation';
|
||||||
|
import { CategoryType } from '../Platform/PlatformConfig';
|
||||||
|
export declare class StationTemplate extends JlGraphicTemplate<JlStation> {
|
||||||
|
hasControl?: boolean;
|
||||||
|
categoryType: CategoryType;
|
||||||
|
constructor(dataTemplate: IStationData, stateTemplate: IXiAnStationState | IBeiJingStationState, categoryType: CategoryType);
|
||||||
|
new(): JlStation;
|
||||||
|
}
|
38
components/Station/StationTemplate.js
Normal file
38
components/Station/StationTemplate.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { JlGraphicTemplate } from 'jl-graphic';
|
||||||
|
import { JlStation } from './JlStation.js';
|
||||||
|
import { XiAnStation } from './XiAnStation.js';
|
||||||
|
import { BeiJingStation } from './BeiJingStation.js';
|
||||||
|
import { CategoryType } from '../Platform/PlatformConfig.js';
|
||||||
|
|
||||||
|
class StationTemplate extends JlGraphicTemplate {
|
||||||
|
hasControl;
|
||||||
|
categoryType;
|
||||||
|
constructor(dataTemplate, stateTemplate, categoryType) {
|
||||||
|
super(JlStation.Type, {
|
||||||
|
dataTemplate,
|
||||||
|
stateTemplate,
|
||||||
|
});
|
||||||
|
this.categoryType = categoryType;
|
||||||
|
switch (this.categoryType) {
|
||||||
|
case CategoryType.XiAn:
|
||||||
|
this.hasControl = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new() {
|
||||||
|
switch (this.categoryType) {
|
||||||
|
case CategoryType.BeiJing:
|
||||||
|
const BeiJing = new BeiJingStation();
|
||||||
|
BeiJing.loadData(this.datas);
|
||||||
|
BeiJing.loadState(this.states);
|
||||||
|
return BeiJing;
|
||||||
|
default:
|
||||||
|
const XiAn = new XiAnStation();
|
||||||
|
XiAn.loadData(this.datas);
|
||||||
|
XiAn.loadState(this.states);
|
||||||
|
return XiAn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { StationTemplate };
|
20
components/Station/XiAnStation.d.ts
vendored
Normal file
20
components/Station/XiAnStation.d.ts
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { GraphicState } from 'jl-graphic';
|
||||||
|
import { JlStation } from './JlStation';
|
||||||
|
export interface IXiAnStationState extends GraphicState {
|
||||||
|
get ipRtuStusDown(): boolean;
|
||||||
|
set ipRtuStusDown(v: boolean);
|
||||||
|
get ipRtuStusInLocalCtrl(): boolean;
|
||||||
|
set ipRtuStusInLocalCtrl(v: boolean);
|
||||||
|
get ipRtuStusInCentralCtrl(): boolean;
|
||||||
|
set ipRtuStusInCentralCtrl(v: boolean);
|
||||||
|
get ipRtuStusInEmergencyCtrl(): boolean;
|
||||||
|
set ipRtuStusInEmergencyCtrl(v: boolean);
|
||||||
|
get rtuId(): number;
|
||||||
|
set rtuId(v: number);
|
||||||
|
}
|
||||||
|
export declare class XiAnStation extends JlStation {
|
||||||
|
_ipRtuStusDown: boolean;
|
||||||
|
constructor();
|
||||||
|
get states(): IXiAnStationState;
|
||||||
|
doRepaint(): void;
|
||||||
|
}
|
42
components/Station/XiAnStation.js
Normal file
42
components/Station/XiAnStation.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { JlStation } from './JlStation.js';
|
||||||
|
import { CategoryType } from '../Platform/PlatformConfig.js';
|
||||||
|
import { XiAnConsts } from './StationConfig.js';
|
||||||
|
|
||||||
|
class XiAnStation extends JlStation {
|
||||||
|
_ipRtuStusDown = false;
|
||||||
|
constructor() {
|
||||||
|
super(CategoryType.XiAn);
|
||||||
|
}
|
||||||
|
get states() {
|
||||||
|
return this.getStates();
|
||||||
|
}
|
||||||
|
doRepaint() {
|
||||||
|
if (this.datas.hasControl && this.controlGraphic) {
|
||||||
|
this.controlGraphic.constrolConfig =
|
||||||
|
XiAnConsts.constrolGraphic.constrolConfig;
|
||||||
|
this.controlGraphic.stateArrowFillColor =
|
||||||
|
XiAnConsts.constrolGraphic.inArrowConfig.inArrowFillColorGray;
|
||||||
|
if (this.states.ipRtuStusInLocalCtrl) {
|
||||||
|
this.controlGraphic.constrolConfig.forEach((item) => {
|
||||||
|
if (item.codeText === '站控') {
|
||||||
|
item.circleFillColor = '0xFFFA0C';
|
||||||
|
}
|
||||||
|
else if (item.codeText === '中控') {
|
||||||
|
item.circleFillColor = '0x808080';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!this.states.ipRtuStusDown) {
|
||||||
|
this.controlGraphic.stateArrowFillColor ==
|
||||||
|
XiAnConsts.constrolGraphic.inArrowConfig.inArrowFillColorBlue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.doRepaint();
|
||||||
|
if (this.states.ipRtuStusDown !== this._ipRtuStusDown) {
|
||||||
|
this._ipRtuStusDown = this.states.ipRtuStusDown;
|
||||||
|
//this.handleBlueShow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { XiAnStation };
|
@ -12,10 +12,6 @@ import { JlPlatform } from './JlPlatform';
|
|||||||
import { PlatformTemplate } from './PlatformTemplate';
|
import { PlatformTemplate } from './PlatformTemplate';
|
||||||
import { CategoryType, IPlatformData } from './PlatformConfig';
|
import { CategoryType, IPlatformData } from './PlatformConfig';
|
||||||
|
|
||||||
export interface IPlatformDrawOptions {
|
|
||||||
newData: () => IPlatformData;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class PlatformDraw extends GraphicDrawAssistant<
|
export class PlatformDraw extends GraphicDrawAssistant<
|
||||||
PlatformTemplate,
|
PlatformTemplate,
|
||||||
IPlatformData
|
IPlatformData
|
||||||
@ -25,7 +21,7 @@ export class PlatformDraw extends GraphicDrawAssistant<
|
|||||||
super(app, template, icon, '站台Platform');
|
super(app, template, icon, '站台Platform');
|
||||||
this.platformGraphic = this.graphicTemplate.new();
|
this.platformGraphic = this.graphicTemplate.new();
|
||||||
this.container.addChild(this.platformGraphic);
|
this.container.addChild(this.platformGraphic);
|
||||||
platformInteraction.init(app);
|
PlatformInteraction.init(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
bind(): void {
|
bind(): void {
|
||||||
@ -51,7 +47,6 @@ export class PlatformDraw extends GraphicDrawAssistant<
|
|||||||
data.direction = template.direction;
|
data.direction = template.direction;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.transform = this.container.saveTransform();
|
data.transform = this.container.saveTransform();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -75,13 +70,13 @@ function buildAbsorbablePositions(platform: JlPlatform): AbsorbablePosition[] {
|
|||||||
return aps;
|
return aps;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class platformInteraction extends GraphicInteractionPlugin<JlPlatform> {
|
class PlatformInteraction extends GraphicInteractionPlugin<JlPlatform> {
|
||||||
static Name = 'platform_transform';
|
static Name = 'platform_transform';
|
||||||
constructor(app: IDrawApp) {
|
constructor(app: IDrawApp) {
|
||||||
super(platformInteraction.Name, app);
|
super(PlatformInteraction.Name, app);
|
||||||
}
|
}
|
||||||
static init(app: IDrawApp) {
|
static init(app: IDrawApp) {
|
||||||
return new platformInteraction(app);
|
return new PlatformInteraction(app);
|
||||||
}
|
}
|
||||||
filter(...grahpics: JlGraphic[]): JlPlatform[] | undefined {
|
filter(...grahpics: JlGraphic[]): JlPlatform[] | undefined {
|
||||||
return grahpics
|
return grahpics
|
||||||
|
19
src/packages/Station/BeiJingStation.ts
Normal file
19
src/packages/Station/BeiJingStation.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { GraphicState } from 'jl-graphic';
|
||||||
|
import { JlStation } from './JlStation';
|
||||||
|
import { CategoryType } from '../Platform/PlatformConfig';
|
||||||
|
|
||||||
|
export interface IBeiJingStationState extends GraphicState {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class BeiJingStation extends JlStation {
|
||||||
|
constructor() {
|
||||||
|
super(CategoryType.BeiJing);
|
||||||
|
}
|
||||||
|
get states(): IBeiJingStationState {
|
||||||
|
return this.getStates<IBeiJingStationState>();
|
||||||
|
}
|
||||||
|
doRepaint(): void {
|
||||||
|
super.doRepaint();
|
||||||
|
}
|
||||||
|
}
|
@ -40,7 +40,7 @@ class ConstrolGraphic extends Container {
|
|||||||
graphicsPs[i],
|
graphicsPs[i],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
if (constrolConsts.inArrowFillColor) {
|
if (constrolConsts.inArrowConfig) {
|
||||||
const points = [0, 0, 2, 2, 2, 1, 14, 1, 14, -1, 2, -1, 2, -2];
|
const points = [0, 0, 2, 2, 2, 1, 14, 1, 14, -1, 2, -1, 2, -2];
|
||||||
const arrow = new Graphics();
|
const arrow = new Graphics();
|
||||||
arrow
|
arrow
|
||||||
@ -54,7 +54,8 @@ class ConstrolGraphic extends Container {
|
|||||||
this.addChild(arrow);
|
this.addChild(arrow);
|
||||||
const inArrow = new Graphics();
|
const inArrow = new Graphics();
|
||||||
const fillColor =
|
const fillColor =
|
||||||
this.stateArrowFillColor || constrolConsts.inArrowFillColor;
|
this.stateArrowFillColor ||
|
||||||
|
constrolConsts.inArrowConfig.inArrowFillColorGray;
|
||||||
inArrow.beginFill(fillColor).drawPolygon(points).endFill();
|
inArrow.beginFill(fillColor).drawPolygon(points).endFill();
|
||||||
inArrow.position.set(-6.5, constrolConsts.circleOffsetY);
|
inArrow.position.set(-6.5, constrolConsts.circleOffsetY);
|
||||||
this.addChild(inArrow);
|
this.addChild(inArrow);
|
||||||
@ -94,14 +95,13 @@ class ConstrolGraphic extends Container {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class JlStation extends JlGraphic {
|
export abstract class JlStation extends JlGraphic {
|
||||||
static Type = 'station';
|
static Type = 'station';
|
||||||
private categoryType: CategoryType;
|
private categoryType: CategoryType;
|
||||||
stationConsts: StationConstsConfig;
|
private stationConsts: StationConstsConfig;
|
||||||
codeGraph: VectorText = new VectorText(''); //车站名
|
codeGraph: VectorText = new VectorText(''); //车站名
|
||||||
kilometerGraph: VectorText = new VectorText(''); //公里标
|
kilometerGraph: VectorText = new VectorText(''); //公里标
|
||||||
controlGraphic?: ConstrolGraphic;
|
controlGraphic?: ConstrolGraphic;
|
||||||
_ipRtuStusDown = false;
|
|
||||||
constructor(categoryType: CategoryType) {
|
constructor(categoryType: CategoryType) {
|
||||||
super(JlStation.Type);
|
super(JlStation.Type);
|
||||||
this.categoryType = categoryType;
|
this.categoryType = categoryType;
|
||||||
|
@ -18,7 +18,7 @@ export interface ConstrolConstsConfig {
|
|||||||
circleOffsetY: number;
|
circleOffsetY: number;
|
||||||
circleBetweenOffset: number;
|
circleBetweenOffset: number;
|
||||||
constrolConfig: ConstrolItemConfig[];
|
constrolConfig: ConstrolItemConfig[];
|
||||||
inArrowFillColor?: string;
|
inArrowConfig?: InArrowConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConstrolItemConfig {
|
export interface ConstrolItemConfig {
|
||||||
@ -27,6 +27,11 @@ export interface ConstrolItemConfig {
|
|||||||
codeGraphFillColor: string;
|
codeGraphFillColor: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface InArrowConfig {
|
||||||
|
inArrowFillColorGray: string;
|
||||||
|
inArrowFillColorBlue: string;
|
||||||
|
}
|
||||||
|
|
||||||
export const BeiJingConsts = {
|
export const BeiJingConsts = {
|
||||||
codeColor: '0xF48815',
|
codeColor: '0xF48815',
|
||||||
codeFontSize: 22,
|
codeFontSize: 22,
|
||||||
@ -48,7 +53,6 @@ export const XiAnConsts = {
|
|||||||
codeOffsetY: 30,
|
codeOffsetY: 30,
|
||||||
circleOffsetY: 20,
|
circleOffsetY: 20,
|
||||||
circleBetweenOffset: 40,
|
circleBetweenOffset: 40,
|
||||||
inArrowFillColor: '0x808080',
|
|
||||||
constrolConfig: [
|
constrolConfig: [
|
||||||
{
|
{
|
||||||
codeText: '中控',
|
codeText: '中控',
|
||||||
@ -61,6 +65,10 @@ export const XiAnConsts = {
|
|||||||
codeGraphFillColor: '0xFFFFFF',
|
codeGraphFillColor: '0xFFFFFF',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
inArrowConfig: {
|
||||||
|
inArrowFillColorGray: '0x808080',
|
||||||
|
inArrowFillColorBlue: '0x08F80D',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -113,13 +121,15 @@ export const stationConstsMap = new Map<CategoryType, StationConstsConfig>([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
export interface IStationData extends GraphicData {
|
export interface IStationData extends GraphicData {
|
||||||
code: string; // 车站索引
|
code: string; // 西安车站索引--北京车站站名
|
||||||
|
stationName: string; // 车站名--北京
|
||||||
kilometerSystem: KilometerSystem;
|
kilometerSystem: KilometerSystem;
|
||||||
hasControl: boolean; //是否有控制
|
hasControl?: boolean; //是否有控制
|
||||||
concentrationStations: boolean; //是否集中站
|
concentrationStations: boolean; //是否集中站
|
||||||
name: string; //车站名称
|
name: string; //车站名称
|
||||||
manageStations: number[]; //集中站管理的车站
|
manageStations: number[]; //集中站管理的车站
|
||||||
depots: boolean; //是否车辆段
|
depots: boolean; //是否车辆段
|
||||||
|
refIbpMapCode?: string;
|
||||||
clone(): IStationData;
|
clone(): IStationData;
|
||||||
copyFrom(data: IStationData): void;
|
copyFrom(data: IStationData): void;
|
||||||
eq(other: IStationData): boolean;
|
eq(other: IStationData): boolean;
|
||||||
|
101
src/packages/Station/StationDrawAssistant.ts
Normal file
101
src/packages/Station/StationDrawAssistant.ts
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import { FederatedPointerEvent, Point } from 'pixi.js';
|
||||||
|
import {
|
||||||
|
AbsorbableLine,
|
||||||
|
AbsorbablePosition,
|
||||||
|
GraphicDrawAssistant,
|
||||||
|
GraphicInteractionPlugin,
|
||||||
|
IDrawApp,
|
||||||
|
JlGraphic,
|
||||||
|
} from 'jl-graphic';
|
||||||
|
import { JlStation } from './JlStation';
|
||||||
|
import { IStationData } from './StationConfig';
|
||||||
|
import { StationTemplate } from './StationTemplate';
|
||||||
|
import { CategoryType } from '../Platform/PlatformConfig';
|
||||||
|
|
||||||
|
export class StationDraw extends GraphicDrawAssistant<
|
||||||
|
StationTemplate,
|
||||||
|
IStationData
|
||||||
|
> {
|
||||||
|
codeGraph: JlStation;
|
||||||
|
constructor(app: IDrawApp, template: StationTemplate, icon: string) {
|
||||||
|
super(app, template, icon, '车站Station');
|
||||||
|
this.codeGraph = this.graphicTemplate.new();
|
||||||
|
this.container.addChild(this.codeGraph);
|
||||||
|
StationInteraction.init(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
bind(): void {
|
||||||
|
super.bind();
|
||||||
|
this.codeGraph.loadData(this.graphicTemplate.datas);
|
||||||
|
this.codeGraph.doRepaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
onLeftDown(e: FederatedPointerEvent): void {
|
||||||
|
this.container.position.copyFrom(this.toCanvasCoordinates(e.global));
|
||||||
|
this.createAndStore(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
redraw(p: Point): void {
|
||||||
|
this.container.position.copyFrom(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
prepareData(data: IStationData): boolean {
|
||||||
|
const template = this.graphicTemplate;
|
||||||
|
switch (template.categoryType) {
|
||||||
|
case CategoryType.XiAn:
|
||||||
|
data.hasControl = this.graphicTemplate.hasControl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
data.transform = this.container.saveTransform();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildAbsorbablePositions(station: JlStation): AbsorbablePosition[] {
|
||||||
|
const aps: AbsorbablePosition[] = [];
|
||||||
|
const stations = station.queryStore.queryByType<JlStation>(JlStation.Type);
|
||||||
|
const { width } = station.getGraphicApp().canvas;
|
||||||
|
stations.forEach((other) => {
|
||||||
|
if (other.id == station.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ps = other.datas.transform.position;
|
||||||
|
const xs = new AbsorbableLine({ x: 0, y: ps.y }, { x: width, y: ps.y });
|
||||||
|
aps.push(xs);
|
||||||
|
});
|
||||||
|
return aps;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class StationInteraction extends GraphicInteractionPlugin<JlStation> {
|
||||||
|
static Name = 'station_transform';
|
||||||
|
constructor(app: IDrawApp) {
|
||||||
|
super(StationInteraction.Name, app);
|
||||||
|
}
|
||||||
|
static init(app: IDrawApp) {
|
||||||
|
return new StationInteraction(app);
|
||||||
|
}
|
||||||
|
filter(...grahpics: JlGraphic[]): JlStation[] | undefined {
|
||||||
|
return grahpics
|
||||||
|
.filter((g) => g.type === JlStation.Type)
|
||||||
|
.map((g) => g as JlStation);
|
||||||
|
}
|
||||||
|
bind(g: JlStation): void {
|
||||||
|
g.eventMode = 'static';
|
||||||
|
g.cursor = 'pointer';
|
||||||
|
g.scalable = true;
|
||||||
|
g.rotatable = true;
|
||||||
|
g.on('selected', this.onSelected, this);
|
||||||
|
}
|
||||||
|
unbind(g: JlStation): void {
|
||||||
|
g.eventMode = 'none';
|
||||||
|
g.scalable = false;
|
||||||
|
g.rotatable = false;
|
||||||
|
g.off('selected', this.onSelected, this);
|
||||||
|
}
|
||||||
|
onSelected(): void {
|
||||||
|
const station = this.app.selectedGraphics[0] as JlStation;
|
||||||
|
this.app.setOptions({
|
||||||
|
absorbablePositions: buildAbsorbablePositions(station),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
41
src/packages/Station/StationTemplate.ts
Normal file
41
src/packages/Station/StationTemplate.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { JlGraphicTemplate } from 'jl-graphic';
|
||||||
|
import { JlStation } from './JlStation';
|
||||||
|
import { IStationData } from './StationConfig';
|
||||||
|
import { IXiAnStationState, XiAnStation } from './XiAnStation';
|
||||||
|
import { BeiJingStation, IBeiJingStationState } from './BeiJingStation';
|
||||||
|
import { CategoryType } from '../Platform/PlatformConfig';
|
||||||
|
|
||||||
|
export class StationTemplate extends JlGraphicTemplate<JlStation> {
|
||||||
|
hasControl?: boolean;
|
||||||
|
categoryType: CategoryType;
|
||||||
|
constructor(
|
||||||
|
dataTemplate: IStationData,
|
||||||
|
stateTemplate: IXiAnStationState | IBeiJingStationState,
|
||||||
|
categoryType: CategoryType,
|
||||||
|
) {
|
||||||
|
super(JlStation.Type, {
|
||||||
|
dataTemplate,
|
||||||
|
stateTemplate,
|
||||||
|
});
|
||||||
|
this.categoryType = categoryType;
|
||||||
|
switch (this.categoryType) {
|
||||||
|
case CategoryType.XiAn:
|
||||||
|
this.hasControl = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new(): JlStation {
|
||||||
|
switch (this.categoryType) {
|
||||||
|
case CategoryType.BeiJing:
|
||||||
|
const BeiJing = new BeiJingStation();
|
||||||
|
BeiJing.loadData(this.datas);
|
||||||
|
BeiJing.loadState(this.states);
|
||||||
|
return BeiJing;
|
||||||
|
default:
|
||||||
|
const XiAn = new XiAnStation();
|
||||||
|
XiAn.loadData(this.datas);
|
||||||
|
XiAn.loadState(this.states);
|
||||||
|
return XiAn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
87
src/packages/Station/XiAnStation.ts
Normal file
87
src/packages/Station/XiAnStation.ts
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
import { GraphicState } from 'jl-graphic';
|
||||||
|
import { JlStation } from './JlStation';
|
||||||
|
import { CategoryType } from '../Platform/PlatformConfig';
|
||||||
|
import { XiAnConsts } from './StationConfig';
|
||||||
|
|
||||||
|
export interface IXiAnStationState extends GraphicState {
|
||||||
|
get ipRtuStusDown(): boolean; //通信终端---是否允许转到中控
|
||||||
|
set ipRtuStusDown(v: boolean);
|
||||||
|
get ipRtuStusInLocalCtrl(): boolean; //站控
|
||||||
|
set ipRtuStusInLocalCtrl(v: boolean);
|
||||||
|
get ipRtuStusInCentralCtrl(): boolean; //遥控
|
||||||
|
set ipRtuStusInCentralCtrl(v: boolean);
|
||||||
|
get ipRtuStusInEmergencyCtrl(): boolean; //紧急站控
|
||||||
|
set ipRtuStusInEmergencyCtrl(v: boolean);
|
||||||
|
get rtuId(): number; // 集中站站号
|
||||||
|
set rtuId(v: number);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class XiAnStation extends JlStation {
|
||||||
|
_ipRtuStusDown = false;
|
||||||
|
constructor() {
|
||||||
|
super(CategoryType.XiAn);
|
||||||
|
}
|
||||||
|
get states(): IXiAnStationState {
|
||||||
|
return this.getStates<IXiAnStationState>();
|
||||||
|
}
|
||||||
|
doRepaint(): void {
|
||||||
|
if (this.datas.hasControl && this.controlGraphic) {
|
||||||
|
this.controlGraphic.constrolConfig =
|
||||||
|
XiAnConsts.constrolGraphic.constrolConfig;
|
||||||
|
this.controlGraphic.stateArrowFillColor =
|
||||||
|
XiAnConsts.constrolGraphic.inArrowConfig.inArrowFillColorGray;
|
||||||
|
if (this.states.ipRtuStusInLocalCtrl) {
|
||||||
|
this.controlGraphic.constrolConfig.forEach((item) => {
|
||||||
|
if (item.codeText === '站控') {
|
||||||
|
item.circleFillColor = '0xFFFA0C';
|
||||||
|
} else if (item.codeText === '中控') {
|
||||||
|
item.circleFillColor = '0x808080';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!this.states.ipRtuStusDown) {
|
||||||
|
this.controlGraphic.stateArrowFillColor ==
|
||||||
|
XiAnConsts.constrolGraphic.inArrowConfig.inArrowFillColorBlue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.doRepaint();
|
||||||
|
if (this.states.ipRtuStusDown !== this._ipRtuStusDown) {
|
||||||
|
this._ipRtuStusDown = this.states.ipRtuStusDown;
|
||||||
|
//this.handleBlueShow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* handleBlueShow() {
|
||||||
|
const signals = this.queryStore.queryByType<Signal>(Signal.Type);
|
||||||
|
const logicSections = this.queryStore.queryByType<LogicSection>(
|
||||||
|
LogicSection.Type
|
||||||
|
);
|
||||||
|
const turnouts = this.queryStore.queryByType<Turnout>(Turnout.Type);
|
||||||
|
const platfroms = this.queryStore.queryByType<Platform>(Platform.Type);
|
||||||
|
const trains = this.queryStore.queryByType<Train>(Train.Type);
|
||||||
|
signals.forEach((signal) => {
|
||||||
|
if (signal.states.rtuId === this.states.rtuId) {
|
||||||
|
signal.doRepaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
logicSections.forEach((logicSection) => {
|
||||||
|
if (logicSection.states.rtuId === this.states.rtuId) {
|
||||||
|
logicSection.doRepaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
turnouts.forEach((turnout) => {
|
||||||
|
if (turnout.states.rtuId === this.states.rtuId) {
|
||||||
|
turnout.doRepaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
platfroms.forEach((platform) => {
|
||||||
|
if (platform.states.rtuId === this.states.rtuId) {
|
||||||
|
platform.doRepaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
trains.forEach((train) => {
|
||||||
|
if (train.states.rtuId === this.states.rtuId) {
|
||||||
|
train.doRepaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} */
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user