道岔测试
This commit is contained in:
parent
bd7bbcc54c
commit
f87f2178fb
4
components/packages/Turnout/THTurnout.d.ts
vendored
4
components/packages/Turnout/THTurnout.d.ts
vendored
@ -28,12 +28,14 @@ export interface ITHTurnoutState extends GraphicState {
|
||||
export declare class THTurnout extends JlTurnout {
|
||||
labelRect: Graphics;
|
||||
speedLimit: Graphics;
|
||||
lostIndicationSquare: Graphics;
|
||||
deltaTime: number;
|
||||
constructor();
|
||||
get states(): ITHTurnoutState;
|
||||
doRepaint(): void;
|
||||
setLineColor(color: string): void;
|
||||
getSpeedLimitLinePoints(conf: 'normal' | 'reverse' | 'main'): IPointData[][];
|
||||
bindFlashAnimation(gList: Graphics[]): GraphicAnimation;
|
||||
bindFlashAnimation(gList: Graphics[], name: string): GraphicAnimation;
|
||||
buildRelation(): void;
|
||||
saveRelations(): void;
|
||||
loadRelations(): void;
|
||||
|
@ -11,16 +11,17 @@ const TurnoutLabelColor = {
|
||||
RED: '#f00',
|
||||
WHITE: '#fff',
|
||||
};
|
||||
//ForkGraphic单独处理
|
||||
class THTurnout extends JlTurnout {
|
||||
labelRect;
|
||||
speedLimit;
|
||||
lostIndicationSquare;
|
||||
deltaTime;
|
||||
constructor() {
|
||||
super(THConsts);
|
||||
this.name = 'turnout';
|
||||
this.labelRect = new Graphics();
|
||||
this.speedLimit = new Graphics();
|
||||
this.lostIndicationSquare = new Graphics();
|
||||
this.addChild(this.labelRect);
|
||||
this.addChild(this.speedLimit);
|
||||
this.deltaTime = 0;
|
||||
@ -32,31 +33,58 @@ class THTurnout extends JlTurnout {
|
||||
//线条颜色
|
||||
const station = this.queryStore.queryByCodeAndType(this.states.rtuId > 9 ? '' + this.states.rtuId : '0' + this.states.rtuId, THStation.Type);
|
||||
if (station?.states.ipRtuStusDown) {
|
||||
this.graphics.sections.forEach((g) => (g.stateFillColor = THConsts.blueShowColor));
|
||||
this.setLineColor(THConsts.blueShowColor);
|
||||
}
|
||||
else if (this.states.ipSingleSwitchStusCbtcOccupied) {
|
||||
this.graphics.sections.forEach((g) => (g.stateFillColor = THConsts.cbtcOccupiedColor));
|
||||
this.setLineColor(THConsts.cbtcOccupiedColor);
|
||||
}
|
||||
else if (this.states.ipSingleSwitchStusCiOccupied) {
|
||||
this.graphics.sections.forEach((g) => (g.stateFillColor = THConsts.ciOccupiedColor));
|
||||
this.setLineColor(THConsts.ciOccupiedColor);
|
||||
}
|
||||
else if (this.states.ipSingleSwitchStusLocked ||
|
||||
this.states.ipSingleSwitchStusFailLocked) {
|
||||
this.graphics.sections.forEach((g) => (g.stateFillColor = THConsts.lockedColor));
|
||||
this.setLineColor(THConsts.lockedColor);
|
||||
}
|
||||
else if (this.states.ipSingleSwitchStusAtcInvalid) {
|
||||
this.graphics.sections.forEach((g) => (g.stateFillColor = THConsts.atcInvalidColor));
|
||||
this.setLineColor(THConsts.atcInvalidColor);
|
||||
}
|
||||
else if (this.states.ipSingleSwitchStusOverlap) {
|
||||
this.graphics.sections.forEach((g) => (g.stateFillColor = THConsts.overlapColor));
|
||||
this.setLineColor(THConsts.overlapColor);
|
||||
}
|
||||
else {
|
||||
this.graphics.sections.forEach((g) => (g.stateFillColor = THConsts.idleColor));
|
||||
this.setLineColor(THConsts.idleColor);
|
||||
}
|
||||
if (this.states.ipSingleSwitchStusJammed /* ||
|
||||
this.turnout.states.ipSingleSwitchStusLostIndication */) {
|
||||
let x, y;
|
||||
const w = 24, h = 24;
|
||||
if (this.datas.pointA[0].x > this.datas.pointB[0].x) {
|
||||
x = -22;
|
||||
}
|
||||
else {
|
||||
x = -2;
|
||||
}
|
||||
if (this.datas.pointC[0].y > 0) {
|
||||
y = -2;
|
||||
}
|
||||
else {
|
||||
y = -20;
|
||||
}
|
||||
this.lostIndicationSquare.lineStyle(2, '#f00').drawRect(x, y, w, h);
|
||||
const flashAnimation = this.bindFlashAnimation([this.lostIndicationSquare], 'lostIndicationFlash');
|
||||
flashAnimation.resume();
|
||||
return;
|
||||
}
|
||||
const { pointB, pointC } = this.datas;
|
||||
if (this.states.ipSingleSwitchStusNormal) {
|
||||
this.graphics.fork.paint(pointB[0]);
|
||||
this.removeAllAnimation();
|
||||
}
|
||||
else if (this.states.ipSingleSwitchStusReverse) {
|
||||
this.graphics.fork.paint(pointC[0]);
|
||||
this.removeAllAnimation();
|
||||
}
|
||||
super.draw();
|
||||
const { pointB, pointC } = this.datas;
|
||||
this.graphics.fork.paint(pointB[0]);
|
||||
this.graphics.fork.paint(pointC[0]);
|
||||
this.graphics.label.text = this.datas.code;
|
||||
//文字颜色
|
||||
if (this.states.ipSingleSwitchStusBlocked1) {
|
||||
@ -118,18 +146,21 @@ class THTurnout extends JlTurnout {
|
||||
this.graphics.fork,
|
||||
this.graphics.sections[0],
|
||||
this.graphics.sections[1],
|
||||
]);
|
||||
], 'flash');
|
||||
}
|
||||
else if (this.states.ipSingleSwitchStusReverse) {
|
||||
this.bindFlashAnimation([
|
||||
this.graphics.fork,
|
||||
this.graphics.sections[0],
|
||||
this.graphics.sections[2],
|
||||
]);
|
||||
], 'flash');
|
||||
}
|
||||
this.animation('flash')?.resume();
|
||||
}
|
||||
}
|
||||
setLineColor(color) {
|
||||
this.graphics.sections.forEach((g) => (g.stateFillColor = color));
|
||||
}
|
||||
getSpeedLimitLinePoints(conf) {
|
||||
const [pa, pb, pc] = [
|
||||
this.datas.pointA[0],
|
||||
@ -185,9 +216,9 @@ class THTurnout extends JlTurnout {
|
||||
];
|
||||
}
|
||||
}
|
||||
bindFlashAnimation(gList) {
|
||||
bindFlashAnimation(gList, name) {
|
||||
const flashAnimation = GraphicAnimation.init({
|
||||
name: 'flash',
|
||||
name,
|
||||
run: (dt) => {
|
||||
this.deltaTime += dt;
|
||||
if (this.deltaTime > 60) {
|
||||
|
@ -4,7 +4,7 @@ import { DevicePort } from 'common/common';
|
||||
import { ITurnoutData, TurnoutConstsConfig } from './TurnoutConfig';
|
||||
import { JlSection } from 'src/packages/Section/common/JlSection';
|
||||
export declare function getForkPoint(r: number, p: IPointData): IPointData;
|
||||
declare class TurnoutSection extends Graphics {
|
||||
export declare class TurnoutSection extends Graphics {
|
||||
turnoutConsts: TurnoutConstsConfig;
|
||||
turnout: JlTurnout;
|
||||
port: DevicePort;
|
||||
@ -16,6 +16,7 @@ declare class ForkGraphic extends Graphics {
|
||||
turnoutConsts: TurnoutConstsConfig;
|
||||
turnout: JlTurnout;
|
||||
stateFillColor?: string;
|
||||
dt: number;
|
||||
constructor(turnout: JlTurnout, turnoutConsts: TurnoutConstsConfig);
|
||||
paint(p: IPointData): void;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ class ForkGraphic extends Graphics {
|
||||
turnoutConsts;
|
||||
turnout;
|
||||
stateFillColor;
|
||||
dt = 0;
|
||||
constructor(turnout, turnoutConsts) {
|
||||
super();
|
||||
this.turnoutConsts = turnoutConsts;
|
||||
@ -66,7 +67,7 @@ class ForkGraphic extends Graphics {
|
||||
}
|
||||
}
|
||||
class JlTurnout extends JlGraphic {
|
||||
static Type = 'JlTurnout';
|
||||
static Type = 'Turnout';
|
||||
graphics;
|
||||
constructor(turnoutConsts) {
|
||||
super(JlTurnout.Type);
|
||||
@ -231,4 +232,4 @@ class JlTurnout extends JlGraphic {
|
||||
}
|
||||
}
|
||||
|
||||
export { JlTurnout, getForkPoint };
|
||||
export { JlTurnout, TurnoutSection, getForkPoint };
|
||||
|
@ -42,16 +42,17 @@ export interface ITHTurnoutState extends GraphicState {
|
||||
rtuId: number;
|
||||
}
|
||||
|
||||
//ForkGraphic单独处理
|
||||
export class THTurnout extends JlTurnout {
|
||||
labelRect: Graphics;
|
||||
speedLimit: Graphics;
|
||||
lostIndicationSquare: Graphics;
|
||||
deltaTime: number;
|
||||
constructor() {
|
||||
super(THConsts);
|
||||
this.name = 'turnout';
|
||||
this.labelRect = new Graphics();
|
||||
this.speedLimit = new Graphics();
|
||||
this.lostIndicationSquare = new Graphics();
|
||||
this.addChild(this.labelRect);
|
||||
this.addChild(this.speedLimit);
|
||||
this.deltaTime = 0;
|
||||
@ -66,42 +67,60 @@ export class THTurnout extends JlTurnout {
|
||||
THStation.Type,
|
||||
);
|
||||
if (station?.states.ipRtuStusDown) {
|
||||
this.graphics.sections.forEach(
|
||||
(g) => (g.stateFillColor = THConsts.blueShowColor),
|
||||
);
|
||||
this.setLineColor(THConsts.blueShowColor);
|
||||
} else if (this.states.ipSingleSwitchStusCbtcOccupied) {
|
||||
this.graphics.sections.forEach(
|
||||
(g) => (g.stateFillColor = THConsts.cbtcOccupiedColor),
|
||||
);
|
||||
this.setLineColor(THConsts.cbtcOccupiedColor);
|
||||
} else if (this.states.ipSingleSwitchStusCiOccupied) {
|
||||
this.graphics.sections.forEach(
|
||||
(g) => (g.stateFillColor = THConsts.ciOccupiedColor),
|
||||
);
|
||||
this.setLineColor(THConsts.ciOccupiedColor);
|
||||
} else if (
|
||||
this.states.ipSingleSwitchStusLocked ||
|
||||
this.states.ipSingleSwitchStusFailLocked
|
||||
) {
|
||||
this.graphics.sections.forEach(
|
||||
(g) => (g.stateFillColor = THConsts.lockedColor),
|
||||
);
|
||||
this.setLineColor(THConsts.lockedColor);
|
||||
} else if (this.states.ipSingleSwitchStusAtcInvalid) {
|
||||
this.graphics.sections.forEach(
|
||||
(g) => (g.stateFillColor = THConsts.atcInvalidColor),
|
||||
);
|
||||
this.setLineColor(THConsts.atcInvalidColor);
|
||||
} else if (this.states.ipSingleSwitchStusOverlap) {
|
||||
this.graphics.sections.forEach(
|
||||
(g) => (g.stateFillColor = THConsts.overlapColor),
|
||||
);
|
||||
this.setLineColor(THConsts.overlapColor);
|
||||
} else {
|
||||
this.graphics.sections.forEach(
|
||||
(g) => (g.stateFillColor = THConsts.idleColor),
|
||||
this.setLineColor(THConsts.idleColor);
|
||||
}
|
||||
|
||||
if (
|
||||
this.states.ipSingleSwitchStusJammed /* ||
|
||||
this.turnout.states.ipSingleSwitchStusLostIndication */
|
||||
) {
|
||||
let x: number, y: number;
|
||||
const w = 24,
|
||||
h = 24;
|
||||
if (this.datas.pointA[0].x > this.datas.pointB[0].x) {
|
||||
x = -22;
|
||||
} else {
|
||||
x = -2;
|
||||
}
|
||||
if (this.datas.pointC[0].y > 0) {
|
||||
y = -2;
|
||||
} else {
|
||||
y = -20;
|
||||
}
|
||||
this.lostIndicationSquare.lineStyle(2, '#f00').drawRect(x, y, w, h);
|
||||
const flashAnimation = this.bindFlashAnimation(
|
||||
[this.lostIndicationSquare],
|
||||
'lostIndicationFlash',
|
||||
);
|
||||
flashAnimation.resume();
|
||||
return;
|
||||
}
|
||||
|
||||
const { pointB, pointC } = this.datas;
|
||||
if (this.states.ipSingleSwitchStusNormal) {
|
||||
this.graphics.fork.paint(pointB[0]);
|
||||
this.removeAllAnimation();
|
||||
} else if (this.states.ipSingleSwitchStusReverse) {
|
||||
this.graphics.fork.paint(pointC[0]);
|
||||
this.removeAllAnimation();
|
||||
}
|
||||
|
||||
super.draw();
|
||||
const { pointB, pointC } = this.datas;
|
||||
this.graphics.fork.paint(pointB[0]);
|
||||
this.graphics.fork.paint(pointC[0]);
|
||||
|
||||
this.graphics.label.text = this.datas.code;
|
||||
|
||||
@ -170,21 +189,30 @@ export class THTurnout extends JlTurnout {
|
||||
|
||||
if (this.states.ipSingleSwitchStusCut) {
|
||||
if (this.states.ipSingleSwitchStusNormal) {
|
||||
this.bindFlashAnimation([
|
||||
this.graphics.fork,
|
||||
this.graphics.sections[0],
|
||||
this.graphics.sections[1],
|
||||
]);
|
||||
this.bindFlashAnimation(
|
||||
[
|
||||
this.graphics.fork,
|
||||
this.graphics.sections[0],
|
||||
this.graphics.sections[1],
|
||||
],
|
||||
'flash',
|
||||
);
|
||||
} else if (this.states.ipSingleSwitchStusReverse) {
|
||||
this.bindFlashAnimation([
|
||||
this.graphics.fork,
|
||||
this.graphics.sections[0],
|
||||
this.graphics.sections[2],
|
||||
]);
|
||||
this.bindFlashAnimation(
|
||||
[
|
||||
this.graphics.fork,
|
||||
this.graphics.sections[0],
|
||||
this.graphics.sections[2],
|
||||
],
|
||||
'flash',
|
||||
);
|
||||
}
|
||||
this.animation('flash')?.resume();
|
||||
}
|
||||
}
|
||||
setLineColor(color: string) {
|
||||
this.graphics.sections.forEach((g) => (g.stateFillColor = color));
|
||||
}
|
||||
getSpeedLimitLinePoints(conf: 'normal' | 'reverse' | 'main'): IPointData[][] {
|
||||
const [pa, pb, pc] = [
|
||||
this.datas.pointA[0],
|
||||
@ -263,9 +291,9 @@ export class THTurnout extends JlTurnout {
|
||||
];
|
||||
}
|
||||
}
|
||||
bindFlashAnimation(gList: Graphics[]) {
|
||||
bindFlashAnimation(gList: Graphics[], name: string) {
|
||||
const flashAnimation = GraphicAnimation.init({
|
||||
name: 'flash',
|
||||
name,
|
||||
run: (dt: number) => {
|
||||
this.deltaTime += dt;
|
||||
if (this.deltaTime > 60) {
|
||||
|
Loading…
Reference in New Issue
Block a user