2019-07-15 10:06:07 +08:00
|
|
|
/*
|
|
|
|
* 信号机
|
|
|
|
*/
|
|
|
|
|
2019-07-18 10:05:16 +08:00
|
|
|
import ESigPost from './ESigPost';
|
|
|
|
import ESigLmap from './ESigLmap';
|
2019-07-18 17:01:21 +08:00
|
|
|
import ESigPass from './ESigPass';
|
|
|
|
import ESigRoute from './ESigRoute';
|
2019-07-18 10:05:16 +08:00
|
|
|
import ESigButton from './ESigButton';
|
|
|
|
import ETextName from '../element/ETextName';
|
2019-07-16 16:29:31 +08:00
|
|
|
import Group from 'zrender/src/container/Group';
|
2019-07-18 10:05:16 +08:00
|
|
|
import { arrows } from '../utils/ShapePoints';
|
2019-07-15 10:06:07 +08:00
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
class Signal extends Group {
|
|
|
|
constructor({ _code, _type, zlevel, model, state }, style) {
|
2019-07-16 12:01:43 +08:00
|
|
|
super();
|
2019-07-16 16:29:31 +08:00
|
|
|
this._code = _code;
|
|
|
|
this._type = _type;
|
|
|
|
this.zlevel = zlevel;
|
2019-07-15 10:06:07 +08:00
|
|
|
this.model = model;
|
2019-07-16 16:29:31 +08:00
|
|
|
this.state = state;
|
|
|
|
this.style = style;
|
|
|
|
this.count = parseInt(model.lampPositionType);
|
|
|
|
this.lamps = new Array(this.count);
|
|
|
|
this.create();
|
2019-07-18 17:01:21 +08:00
|
|
|
// this.setState(state);
|
2019-07-15 10:06:07 +08:00
|
|
|
}
|
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
create() {
|
2019-07-18 17:01:21 +08:00
|
|
|
const model = this.model;
|
|
|
|
const style = this.style;
|
2019-07-16 16:29:31 +08:00
|
|
|
const drict = this.model.directionType == '01' ? -1 : 1; // 朝向 左:右
|
|
|
|
const posit = this.model.positionType == '01' ? -1 : 1; // 位置 上:下
|
2019-07-15 10:06:07 +08:00
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
// 信号机高柱矮柱
|
2019-07-16 18:37:49 +08:00
|
|
|
this.sigPost = new ESigPost({
|
2019-07-15 10:06:07 +08:00
|
|
|
zlevel: this.zlevel,
|
2019-07-16 16:29:31 +08:00
|
|
|
z: 1,
|
2019-07-18 17:01:21 +08:00
|
|
|
style: style,
|
2019-07-16 16:29:31 +08:00
|
|
|
drict: drict,
|
2019-07-18 17:01:21 +08:00
|
|
|
type: model.lampPostType,
|
|
|
|
x: model.position.x,
|
|
|
|
y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR)
|
2019-07-15 10:06:07 +08:00
|
|
|
});
|
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
// 信号灯
|
2019-07-18 17:01:21 +08:00
|
|
|
const nextPosition = this.sigPost.getLampPosition(model.lampPostType);
|
2019-07-16 16:29:31 +08:00
|
|
|
this.lamps = [];
|
|
|
|
for (let i = 0; i < this.count; i++) {
|
|
|
|
const lamp = new ESigLmap({
|
2019-07-15 10:06:07 +08:00
|
|
|
zlevel: this.zlevel,
|
2019-07-16 16:29:31 +08:00
|
|
|
z: 1,
|
2019-07-18 17:01:21 +08:00
|
|
|
style: style,
|
2019-07-16 16:29:31 +08:00
|
|
|
index: i + 1,
|
|
|
|
drict: drict,
|
2019-07-18 17:01:21 +08:00
|
|
|
x: nextPosition.x + i * drict * style.Signal.signalR * 2,
|
2019-07-16 18:37:49 +08:00
|
|
|
y: nextPosition.y,
|
2019-07-18 17:01:21 +08:00
|
|
|
originX: model.position.x,
|
|
|
|
originY: model.position.y
|
2019-07-15 10:06:07 +08:00
|
|
|
});
|
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
this.lamps.push(lamp);
|
2019-07-15 10:06:07 +08:00
|
|
|
}
|
|
|
|
|
2019-07-16 18:37:49 +08:00
|
|
|
// 信号机名称
|
2019-07-17 09:12:05 +08:00
|
|
|
this.sigName = new ETextName({
|
2019-07-16 18:37:49 +08:00
|
|
|
zlevel: this.zlevel,
|
2019-07-16 18:44:40 +08:00
|
|
|
z: 1,
|
2019-07-18 17:01:21 +08:00
|
|
|
style: style,
|
|
|
|
x: model.position.x + model.namePosition.x,
|
|
|
|
y: model.position.y + posit * (style.Signal.signalDistance + style.Section.sectionWidth + style.Signal.signalR * 2 + model.namePosition.y),
|
|
|
|
text: model.name,
|
|
|
|
textFont: `bold ${style.Signal.signalTextFontSize} px ${style.textFontFormat}`,
|
|
|
|
textFill: style.Signal.sigTextGreen,
|
2019-07-16 18:37:49 +08:00
|
|
|
textAlign: 'middle',
|
|
|
|
textVerticalAlign: posit == 1 ? 'top' : 'bottom'
|
|
|
|
});
|
|
|
|
|
2019-07-18 17:01:21 +08:00
|
|
|
// 自动进路
|
|
|
|
const sigRouteH = style.Signal.signalSigRouteDirection == 0 ? style.Signal.signalR * 2: (this.count + 2)* style.Signal.signalR;
|
|
|
|
const sigRouteX = nextPosition.x - (style.Signal.signalSigRouteOffset.x - sigRouteH) * drict;
|
|
|
|
const sigRouteY = nextPosition.y + (style.Signal.signalSigRouteOffset.y);
|
|
|
|
this.sigRoute = new ESigRoute({
|
2019-07-16 18:37:49 +08:00
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: 1,
|
2019-07-18 17:01:21 +08:00
|
|
|
style: style,
|
|
|
|
x: sigRouteX,
|
|
|
|
y: sigRouteY,
|
2019-07-16 18:37:49 +08:00
|
|
|
drict: drict
|
|
|
|
});
|
|
|
|
|
2019-07-18 17:01:21 +08:00
|
|
|
// 自动通过
|
|
|
|
const x = nextPosition.x + drict * this.count * style.Signal.signalR * 0.8 + drict * (this.count * style.Signal.signalR + style.Signal.signalLampStandardWidth) * 2;
|
|
|
|
const y = nextPosition.y - style.Signal.signalLampStandardWidth;
|
|
|
|
const point = arrows(x, y, style.Signal.signalSigAutoWidt, style.Signal.signalR * 0.8);
|
|
|
|
this.sigPass = new ESigPass({
|
2019-07-16 18:37:49 +08:00
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: 1,
|
2019-07-18 17:01:21 +08:00
|
|
|
style: style,
|
2019-07-16 18:37:49 +08:00
|
|
|
count: this.count,
|
|
|
|
drict: drict,
|
2019-07-17 18:18:28 +08:00
|
|
|
point: point,
|
2019-07-18 17:01:21 +08:00
|
|
|
x: nextPosition.x + drict * this.count * style.Signal.signalR * 0.8,
|
2019-07-16 18:37:49 +08:00
|
|
|
y: nextPosition.y,
|
2019-07-18 17:01:21 +08:00
|
|
|
width: style.Signal.signalSigPassWidth,
|
|
|
|
fill: style.Signal.signalLampGreenColor,
|
2019-07-17 18:18:28 +08:00
|
|
|
lineWidth: 0.6,
|
2019-07-18 17:01:21 +08:00
|
|
|
stroke: style.sidelineColor
|
2019-07-16 18:37:49 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
// 延迟解锁
|
|
|
|
this.sigDelay = new ETextName({
|
|
|
|
zlevel: this.zlevel,
|
2019-07-16 18:44:40 +08:00
|
|
|
z: 1,
|
2019-07-18 17:01:21 +08:00
|
|
|
style: style,
|
|
|
|
x: nextPosition.x + drict * this.count * style.Signal.signalR * 3,
|
2019-07-17 11:19:08 +08:00
|
|
|
y: nextPosition.y,
|
2019-07-17 09:12:05 +08:00
|
|
|
text: this.state.delayCount || '0',
|
2019-07-18 17:01:21 +08:00
|
|
|
textFont: `bold ${style.Signal.signalDelayTextFontSize} px ${style.textFontFormat}`,
|
|
|
|
textFill: style.Signal.signalTextRed,
|
2019-07-16 18:37:49 +08:00
|
|
|
textAlign: drict > 0 ? 'right' : 'left',
|
|
|
|
textVerticalAlign: 'middle'
|
|
|
|
});
|
|
|
|
|
2019-07-15 10:06:07 +08:00
|
|
|
// 信号灯按钮
|
2019-07-16 16:29:31 +08:00
|
|
|
this.sigButton = new ESigButton({
|
2019-07-15 10:06:07 +08:00
|
|
|
zlevel: this.zlevel,
|
2019-07-16 16:29:31 +08:00
|
|
|
z: 1,
|
2019-07-18 17:01:21 +08:00
|
|
|
style: style,
|
2019-07-16 16:29:31 +08:00
|
|
|
posit: posit,
|
2019-07-18 17:01:21 +08:00
|
|
|
show: model.buttonShow,
|
|
|
|
x: model.buttonPosition.x,
|
|
|
|
y: model.buttonPosition.y - posit * (style.Signal.signalButtonDistance + style.Signal.signalR * 2)
|
2019-07-16 16:29:31 +08:00
|
|
|
});
|
2019-07-15 10:06:07 +08:00
|
|
|
|
2019-07-16 18:37:49 +08:00
|
|
|
this.add(this.sigPost);
|
2019-07-16 16:29:31 +08:00
|
|
|
this.lamps.forEach(lamp => { this.add(lamp); });
|
2019-07-16 18:37:49 +08:00
|
|
|
this.add(this.sigName);
|
2019-07-18 17:01:21 +08:00
|
|
|
this.add(this.sigPass);
|
|
|
|
this.add(this.sigRoute);
|
2019-07-16 18:37:49 +08:00
|
|
|
this.add(this.sigDelay);
|
2019-07-16 16:29:31 +08:00
|
|
|
// this.add(this.sigButton);
|
2019-07-15 10:06:07 +08:00
|
|
|
}
|
|
|
|
|
2019-07-16 18:37:49 +08:00
|
|
|
// 关闭
|
|
|
|
close() {
|
|
|
|
if (this.count === 1) {
|
|
|
|
if (this.model.useType === '05') {
|
|
|
|
/** 单灯 调车信号机*/
|
|
|
|
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampBlueColor);
|
|
|
|
} else {
|
|
|
|
/** 单灯 出站信号机 */
|
|
|
|
/** 单灯 阻挡信号机*/
|
|
|
|
/** 单灯 阻挡兼调车信号 */
|
|
|
|
/** 单灯 列兼调信号机 */
|
|
|
|
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampRedColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 开放
|
|
|
|
open() {
|
|
|
|
if (this.count === 1) {
|
|
|
|
/** 单灯 出站信号机*/
|
|
|
|
/** 单灯 阻隔信号机*/
|
|
|
|
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampGreenColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 列车进路
|
|
|
|
trainRoute() {
|
|
|
|
if (this.count === 1) {
|
|
|
|
/** 单灯 列兼调信号*/
|
|
|
|
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampYellowColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 调车进路
|
|
|
|
shuntRoute() {
|
|
|
|
if (this.count === 1) {
|
|
|
|
/** 单灯 列兼调信号*/
|
|
|
|
/** 单灯 阻挡兼调车信号*/
|
|
|
|
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampWhiteColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 引导
|
|
|
|
guid() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 封锁
|
|
|
|
block() {
|
|
|
|
this.lamps[0] && this.lamps[0].setColor(this.style.Signal.signalLampRedColor);
|
|
|
|
this.sigName.setColor(this.style.Signal.sectionBlockTextColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 功能封锁
|
|
|
|
functionBlock() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 信号保护区段监视状态显示
|
|
|
|
signalblock() {
|
|
|
|
}
|
|
|
|
|
|
|
|
// 故障
|
|
|
|
fault() {
|
|
|
|
}
|
|
|
|
|
|
|
|
// 物理点灯
|
|
|
|
logicalLight() {
|
|
|
|
this.lamps.forEach(lamp => { lamp.setStop(false); });
|
|
|
|
}
|
|
|
|
|
|
|
|
// 逻辑点灯
|
|
|
|
physicsLight() {
|
|
|
|
this.lamps.forEach(lamp => { lamp.setStop(true); });
|
|
|
|
}
|
|
|
|
|
|
|
|
// 设置自动进路模式状态类型
|
|
|
|
setAutoRouteOpen() {
|
|
|
|
if (this.model.linkageAutoRouteShow) {
|
2019-07-18 17:01:21 +08:00
|
|
|
this.sigPass.show();
|
2019-07-16 18:37:49 +08:00
|
|
|
} else {
|
2019-07-18 17:01:21 +08:00
|
|
|
this.sigPass.hide();
|
2019-07-16 18:37:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
this.recover();
|
2019-07-18 17:01:21 +08:00
|
|
|
this.sigPass.setColor(this.style.Signal.signalLampGreenColor);
|
2019-07-16 18:37:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 信号机进路自动触发模式状态类型
|
|
|
|
setAutoAccessOpen() {
|
|
|
|
if (this.model.atsAutoTriggerShow) {
|
2019-07-18 17:01:21 +08:00
|
|
|
this.sigPass.show();
|
2019-07-16 18:37:49 +08:00
|
|
|
} else {
|
2019-07-18 17:01:21 +08:00
|
|
|
this.sigPass.hide();
|
2019-07-16 18:37:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
this.recover();
|
2019-07-18 17:01:21 +08:00
|
|
|
this.sigPass.setColor(this.style.Signal.signalLampYellowColor);
|
2019-07-16 18:37:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 设置自动信号模式状态类型
|
|
|
|
setAutoSignalOpen() {
|
2019-07-18 17:01:21 +08:00
|
|
|
this.sigRoute.show();
|
2019-07-16 18:37:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 隐藏自动信号和自动进路
|
|
|
|
setAutoClose() {
|
2019-07-18 17:01:21 +08:00
|
|
|
this.sigPass.hide();
|
|
|
|
this.sigPass.setColor(this.style.backgroundColor);
|
|
|
|
this.sigRoute.hide();
|
2019-07-16 18:37:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 自动信号和自动进路开始动画
|
|
|
|
setAutoFlicker() {
|
2019-07-18 17:01:21 +08:00
|
|
|
this.sigPass.arrowsAnimation();
|
2019-07-16 18:37:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 设置延时解锁
|
|
|
|
setDelayUnlock() {
|
|
|
|
this.sigDelay.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 恢复状态
|
|
|
|
recover() {
|
|
|
|
this.sigDelay.hide();
|
2019-07-18 17:01:21 +08:00
|
|
|
this.sigPass.animationRecover();
|
2019-07-16 18:37:49 +08:00
|
|
|
this.sigName.setColor(this.style.Signal.signalTextGreen);
|
|
|
|
}
|
|
|
|
|
2019-07-15 15:25:49 +08:00
|
|
|
setState(state) {
|
2019-07-16 18:37:49 +08:00
|
|
|
this.recover();
|
|
|
|
/** 设置状态 (点灯类型)*/
|
|
|
|
switch (state.status) {
|
|
|
|
case '01': this.close(); break; // 关闭
|
|
|
|
case '02': this.open(); break; // 开放
|
|
|
|
case '03': this.guid(); break; // 引导
|
|
|
|
case '04': this.block(); break; // 封锁
|
|
|
|
case '05': this.fault(); break; // 故障
|
|
|
|
case '06': this.block(); break; // 功能封锁
|
|
|
|
case '07': this.signalblock(); break; // 信号保护区段检测
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 进路性质类型*/
|
|
|
|
switch (state.natureType) {
|
|
|
|
case '01': this.trainRoute(); break; // 列车进路
|
|
|
|
case '02': this.shuntRoute(); break; // 调车进路
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 设置点灯类型*/
|
|
|
|
switch (state.lightType) {
|
|
|
|
case '01': this.logicalLight(); break; // 设置逻辑点灯
|
|
|
|
case '02': this.physicsLight(); break; // 设置物理点灯
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 设置自动类型*/
|
|
|
|
switch (state.autoType) {
|
|
|
|
case '01': this.setAutoClose(); break; // 隐藏 隐藏自动信号和自动进路
|
|
|
|
case '02': this.setAutoSignalOpen(); break; // 显示 设置自动信号模式状态类型
|
|
|
|
case '03': this.setAutoRouteOpen(); break; // 显示 设置自动进路模式状态类型
|
|
|
|
case '04': this.setAutoAccessOpen(); break; // 显示 信号机进路自动触发模式状态类型
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 延时解锁*/
|
|
|
|
state.delayType = '02';
|
|
|
|
switch (state.delayType) {
|
|
|
|
case '01': break; // 未延时解锁
|
|
|
|
case '02': break; // 人工闭塞延时解锁
|
|
|
|
case '03': break; // 自动闭塞延时解锁
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 信号机进路办理,先停止动画,再判断当前颜色是否闪烁*/
|
|
|
|
if (state.routeSetting && (state.autoType == '03' || state.autoType == '04')) {
|
|
|
|
this.setAutoFlicker();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getShapeTipPoint(val) {
|
|
|
|
if (val === '1' || val === '2') {
|
|
|
|
// return this.sigButton.getShapeTipPoint(val);
|
|
|
|
} else {
|
|
|
|
// return this.siglamp.getShapeTipPoint(val);
|
|
|
|
}
|
2019-07-15 10:06:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-16 16:29:31 +08:00
|
|
|
export default Signal;
|