修改代码

This commit is contained in:
ival 2019-07-17 15:53:13 +08:00
parent f2651e5844
commit cac49ad418
7 changed files with 780 additions and 221 deletions

View File

@ -1,10 +1,11 @@
/**/
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
import Rect from 'zrender/src/graphic/shape/Rect';
import Isogon from 'zrender/src/graphic/shape/Isogon';
import Polygon from 'zrender/src/graphic/shape/Polygon';
import { flashlight } from './libs/ShapePoints';
import ESafeDoor from './element/ESafeDoor';
import ESafeStand from './element/ESafeStand';
import ESafeEmergent from './element/ESafeEmergent';
class StationStand extends Group {
constructor({ _code, _type, zlevel, model, state }, style) {
@ -15,33 +16,22 @@ class StationStand extends Group {
this.model = model;
this.state = state;
this.style = style;
this.z = 40;
this.doors = new Group();
this._create(model);
this._create();
this.setVisible(model.visible);
this.setState(state);
}
_create(model) {
_create() {
const model = this.model;
const style = this.style;
const drict = model.doorLocationType == '01' ? 1 : -1;
this.stationStand = new Rect({
zlevel: this.zlevel,
z: this.z,
shape: {
x: model.position.x - model.width / 2,
y: 0,
width: model.width,
height: model.height
},
style: {
lineWidth: 0,
stroke: this.style.sidelineColor,
fill: this.style.stationStandSpareColor
}
});
/** 站台折返策略*/
const beyond = 4;
const height = 5;
const width = 10;
const offsetx = (model.width - width / 2);
const offsety = (model.height + height + this.style.stationStandDistance) / 2;
const offsety = (model.height + height + style.StationStand.standDistance) / 2;
this.reentry = new Polygon({
zlevel: this.zlevel,
@ -51,7 +41,7 @@ class StationStand extends Group {
},
style: {
lineWidth: 0,
fill: this.style.stationStandNoHumanReentryColor
fill: style.StationStand.stationNoHumanReentryColor
}
});
this.add(this.reentry);
@ -69,9 +59,9 @@ class StationStand extends Group {
text: 'H',
textAlign: 'middle',
textVerticalAlign: 'top',
fontSize: this.style.stationStandHeadFontSize + 'px ' + this.style.textFontFormat,
textFill: this.style.stationStandCenterDetainTrainColor,
textStroke: this.style.backgroundColor
fontSize: style.StationStand.stationHeadFontSize + 'px ' + style.textFontFormat,
textFill: style.StationStand.stationCenterDetainTrainColor,
textStroke: style.StationStand.backgroundColor
}
});
this.add(this.text);
@ -81,7 +71,7 @@ class StationStand extends Group {
if (model.doorLocationType == '02') {
textLevelT = [0, 5];
}
const timeX = model.position.x - drict * (model.width / 2 + this.style.textFontSize + distance);
const timeX = model.position.x - drict * (model.width / 2 + style.textFontSize + distance);
this.time = new Text({
zlevel: this.zlevel,
z: this.z + 2,
@ -90,9 +80,9 @@ class StationStand extends Group {
x: timeX,
y: 0,
text: model.parkingTime,
textFill: this.style.stationStandTimeTextColor,
textFill: style.StationStand.stationTimeTextColor,
textAlign: 'middle',
textFont: this.style.textFontSize + 'px ' + this.style.textFontFormat
textFont: style.textFontSize + 'px ' + style.textFontFormat
}
});
this.add(this.time);
@ -102,7 +92,7 @@ class StationStand extends Group {
if (model.doorLocationType == '01') {
textLevelP = [0, 15];
}
const levelX = model.position.x - drict * (model.width / 2 + this.style.textFontSize + distance);
const levelX = model.position.x - drict * (model.width / 2 + style.textFontSize + distance);
this.level = new Text({
zlevel: this.zlevel,
z: this.z + 2,
@ -111,144 +101,63 @@ class StationStand extends Group {
x: levelX,
y: 0,
text: model.intervalRunTime,
textFill: this.style.stationStandTimeTextColor,
textFill: style.StationStand.stationTimeTextColor,
textAlign: 'middle',
textFont: this.style.textFontSize + 'px ' + this.style.textFontFormat
textFont: style.textFontSize + 'px ' + style.textFontFormat
}
});
this.add(this.level);
/** 站台紧急关闭*/
this.emergent = new Isogon({
const emergentH = drict ? style.StationStand.standSafeHeight - style.StationStand.standDistance / 2: style.StationStand.standDistance / 2;
const emergentX = model.position.x;
const emergentY = model.position.y + drict * (style.StationStand.standDistance + emergentH);
this.emergent = new ESafeEmergent({
zlevel: this.zlevel,
z: this.z,
shape: {
x: model.position.x,
y: 0,
r: this.style.stationStandDistance / 2,
n: 4
},
style: {
lineWidth: 0,
stroke: this.style.stationStandEmergentCloseColor,
fill: this.style.stationStandEmergentCloseColor
}
style: style,
x: emergentX,
y: emergentY,
r: style.StationStand.standDistance / 2,
n: 4
});
this.doors.add(this.emergent);
/** 屏蔽门*/
const padding = 0.1;
this.safeDoorL = new Rect({
this.safeDoor = new ESafeDoor({
zlevel: this.zlevel,
z: this.z,
shape: {
x: model.position.x - model.width / 2 - padding,
y: model.position.y,
width: model.width / 4 + padding,
height: this.style.statonStandSafeHeight
},
style: {
lineWidth: 0,
stroke: this.style.stationStandDoorDefaultColor,
fill: this.style.stationStandDoorDefaultColor
}
z: 1,
style: style,
x: model.position.x,
y: model.position.y,
width: model.width,
height: style.StationStand.standSafeHeight,
show: model.hasDoor
});
this.safeDoorC = new Rect({
/** 列车站台*/
const standH = drict > 0 ? 0 : model.height;
const standX = model.position.x - model.width / 2;
const standY = model.position.y + drict * (style.StationStand.standDistance + standH);
this.safeStand = new ESafeStand({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x: model.position.x - model.width / 4 - padding,
y: model.position.y,
width: model.width / 2 + padding * 2,
height: this.style.statonStandSafeHeight
},
style: {
lineWidth: 0,
stroke: this.style.stationStandDoorDefaultColor,
fill: this.style.stationStandDoorDefaultColor
}
z: 1,
style: style,
x: standX,
y: standY,
width: model.width,
height: model.height
});
this.safeDoorR = new Rect({
zlevel: this.zlevel,
z: this.z,
shape: {
x: model.position.x + model.width / 4,
y: model.position.y,
width: model.width / 4 + padding,
height: this.style.statonStandSafeHeight
},
style: {
lineWidth: 0,
stroke: this.style.stationStandDoorDefaultColor,
fill: this.style.stationStandDoorDefaultColor
}
});
this.setHasSafeDoor(model.hasDoor);
this.setDrict(model.doorLocationType);
this.setVisible(model.visible);
this.setState(model);
this.mouseStatusRecover();
}
setDrict(doorLocationType) {
const model = this.model;
const style = this.style;
if (doorLocationType === '01') {
const distance = model.position.y + style.stationStandDistance + style.statonStandSafeHeight;
this.text.setStyle('y', distance + model.height / 2 - style.stationStandHeadFontSize / 2);
this.time.setStyle('y', distance + model.height - style.textFontSize);
this.level.setStyle('y', distance - model.height + style.textFontSize / 1.2);
this.emergent.setShape('y', distance - style.stationStandDistance / 2);
this.stationStand.setShape('y', distance);
} else {
const distance = model.position.y - style.stationStandDistance;
this.text.setStyle('y', distance - model.height / 2 - style.stationStandHeadFontSize / 2);
this.time.setStyle('y', distance - model.height + style.textFontSize);
this.level.setStyle('y', distance - model.height - style.textFontSize / 2);
this.emergent.setShape('y', distance + style.stationStandDistance / 2);
this.stationStand.setShape('y', distance - model.height);
}
this.add(this.doors);
this.add(this.stationStand);
const rect = this.stationStand.getBoundingRect();
rect.union(this.doors.getBoundingRect());
this.standBorder = new Rect({
zlevel: this.model.zlevel,
silent: true,
z: this.z - 1,
shape: rect,
style: {
lineDash: [3, 3],
stroke: style.borderColor,
fill: style.transparentColor
}
});
this.add(this.standBorder);
}
setHasSafeDoor(hasDoor) {
if (hasDoor) {
this.doors.add(this.safeDoorL);
this.doors.add(this.safeDoorC);
this.doors.add(this.safeDoorR);
} else {
this.doors.remove(this.safeDoorL);
this.doors.remove(this.safeDoorC);
this.doors.remove(this.safeDoorR);
}
this.add(this.emergent);
this.add(this.safeDoor);
this.add(this.safeStand);
}
setVisible(visible) {
if (visible) {
this.eachChild((it) => {
it.show();
});
this.eachChild(elem => { elem.show(); });
} else {
this.eachChild((it) => {
it.hide();
});
this.eachChild(elem => { elem.hide(); });
}
}
@ -257,33 +166,31 @@ class StationStand extends Group {
this.time.hide();
this.level.hide();
this.text.hide();
this.emergent.hide();
this.reentry.hide();
if (this.model.visible) { this.safeDoorC.show(); }
this.safeDoorL.setStyle('fill', this.style.stationStandDoorDefaultColor);
this.safeDoorC.setStyle('fill', this.style.stationStandDoorDefaultColor);
this.safeDoorR.setStyle('fill', this.style.stationStandDoorDefaultColor);
this.emergent.setVisible(false);
if (this.model.visible) { this.safeDoor.hasDoor(true); }
this.safeDoor.setColor(this.style.StationStand.standDoorDefaultColor);
}
/** 空闲*/
spare() {
this.stationStand.setStyle('fill', this.style.stationStandSpareColor);
this.safeStand.setColor(this.style.StationStand.standSpareColor);
}
/** 列车停站*/
stop() {
this.stationStand.setStyle('fill', this.style.stationStandStopColor);
this.safeStand.setColor(this.style.StationStand.standStopColor);
}
/** 指定列车跳站*/
designatedJumpStop() {
this.stationStand.setStyle('fill', this.style.stationStandDesignatedJumpStopColor);
this.safeStand.setColor(this.style.StationStand.standDesignatedJumpStopColor);
}
/** 站台紧急关闭*/
emergentClose() {
this.stationStand.setStyle('fill', this.style.stationStandSpareColor);
this.emergent.show();
this.safeStand.setColor(this.style.StationStand.standSpareColor);
this.emergent.setVisible(true);
}
/** 未设置跳停*/
@ -292,7 +199,7 @@ class StationStand extends Group {
/** 站台跳停*/
jumpStop() {
this.stationStand.setStyle('fill', this.style.stationStandJumpStopColor);
this.safeStand.setColor(this.style.StationStand.standJumpStopColor);
}
/** 未设置扣车*/
@ -303,13 +210,13 @@ class StationStand extends Group {
/** 车站扣车*/
standDetainTrain() {
this.text.show();
this.text.setStyle('textFill', this.style.stationStandDetainTrainTextColor);
this.text.setStyle('textFill', this.style.StationStand.standDetainTrainTextColor);
}
/** 中心扣车*/
centerDetainTrain() {
this.text.show();
this.text.setStyle('textFill', this.style.stationStandCenterDetainTrainColor);
this.text.setStyle('textFill', this.style.StationStand.standCenterDetainTrainColor);
}
/** 中心+车站扣车*/
@ -339,33 +246,27 @@ class StationStand extends Group {
/** 开门*/
openDoor() {
this.safeDoorC.hide();
this.safeDoor.hasDoor(true);
}
/** 关门*/
closeDoor() {
if (this.model.model.visible) { this.safeDoorC.show(); }
if (this.model.model.visible) { this.safeDoor.hasDoor(false); }
}
/** 屏蔽门正常*/
doorNormal() {
this.safeDoorL.setStyle('fill', this.style.stationStandDoorDefaultColor);
this.safeDoorC.setStyle('fill', this.style.stationStandDoorDefaultColor);
this.safeDoorR.setStyle('fill', this.style.stationStandDoorDefaultColor);
this.safeDoor.setColor(this.style.StationStand.standDoorDefaultColor);
}
/** 屏蔽门故障*/
doorFault() {
this.safeDoorL.setStyle('fill', this.style.stationStandSplitDoorColor);
this.safeDoorC.setStyle('fill', this.style.stationStandSplitDoorColor);
this.safeDoorR.setStyle('fill', this.style.stationStandSplitDoorColor);
this.safeDoor.setColor(this.style.StationStand.standSplitDoorColor);
}
/** 屏蔽门切除*/
doorSplit() {
this.safeDoorL.setStyle('fill', this.style.stationStandSplitDoorColor);
this.safeDoorC.setStyle('fill', this.style.stationStandSplitDoorColor);
this.safeDoorR.setStyle('fill', this.style.stationStandSplitDoorColor);
this.safeDoor.setColor(this.style.StationStand.standSplitDoorColor);
}
/** 无折返(默认)*/
@ -376,17 +277,17 @@ class StationStand extends Group {
/** 无人折返*/
noHumanReentry() {
this.reentry.show();
this.reentry.setStyle('fill', this.style.stationStandNoHumanReentryColor);
this.reentry.setStyle('fill', this.style.StationStand.standNoHumanReentryColor);
}
/** 自动换端*/
autoChangeEnds() {
this.reentry.show();
this.reentry.setStyle('fill', this.style.stationStandAutoChangeEndsColor);
this.reentry.setStyle('fill', this.style.StationStand.standAutoChangeEndsColor);
}
setState(model) {
setState(state) {
this.recover();
switch (model.status) {
switch (state.status) {
case '01': /** 空闲*/
this.spare();
break;
@ -398,17 +299,17 @@ class StationStand extends Group {
break;
}
if (Number(model.parkingTime) >= 0) {
this.setManuallyArmisticeTime(model.parkingTime);
if (Number(state.parkingTime) >= 0) {
this.setManuallyArmisticeTime(state.parkingTime);
}
if (Number(model.intervalRunTime) > 0) {
this.setManuallyOperationLevel(model.intervalRunTime);
if (Number(state.intervalRunTime) > 0) {
this.setManuallyOperationLevel(state.intervalRunTime);
}
/** 设置跳停*/
if (model.status == '01') {
switch (model.jumpStopStatus) {
if (state.status == '01') {
switch (state.jumpStopStatus) {
case '01': /** 未设置跳停*/
this.unJumpStop();
break;
@ -422,7 +323,7 @@ class StationStand extends Group {
}
/** 设置扣车*/
switch (model.holdStatus) {
switch (state.holdStatus) {
case '01': /** 未设置扣车*/
this.unDetainTrain();
break;
@ -438,7 +339,7 @@ class StationStand extends Group {
}
/** 设置屏蔽门开关*/
switch (model.screenDoorOpenStatus) {
switch (state.screenDoorOpenStatus) {
case '01':
this.closeDoor(); /** 关门*/
break;
@ -448,7 +349,7 @@ class StationStand extends Group {
}
/** 设置屏蔽门状态*/
switch (model.screenDoorStatus) {
switch (state.screenDoorStatus) {
case '01':
this.doorNormal(); /** 正常*/
break;
@ -460,7 +361,7 @@ class StationStand extends Group {
}
/** 设置折返策略*/
switch (model.reentryStrategy) {
switch (state.reentryStrategy) {
case '04': /** 默认*/
case '01':
this.noReentry(); /** 无折返策略*/
@ -475,7 +376,7 @@ class StationStand extends Group {
}
getShapeTipPoint() {
const rect = this.stationStand.getBoundingRect();
const rect = this.safeStand.getBoundingRect();
if (rect) {
return {
x: rect.x + rect.width / 2,
@ -484,39 +385,5 @@ class StationStand extends Group {
}
return null;
}
mouseStatusVisible() {
this.standBorder.show();
this.stationStand.setStyle({ fill: this.style.borderContextBackgroundColor});
}
mouseStatusRecover() {
this.standBorder.hide();
this.stationStand.setStyle({ fill: this.style.stationStandSpareColor});
this.setState(this.model);
}
mouseclick(e) {
if ([3].includes(e.which)) {
this.selected = !this.selected;
if (this.selected) {
this.mouseStatusRecover();
this.mouseStatusVisible();
}
}
}
mouseenter(e) {
if (!this.selected) {
this.mouseStatusRecover();
this.mouseStatusVisible();
}
}
mouseleave(e) {
if (!this.selected) {
this.mouseStatusRecover();
}
}
}
export default StationStand;

View File

@ -0,0 +1,487 @@
/**/
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
import Rect from 'zrender/src/graphic/shape/Rect';
import Isogon from 'zrender/src/graphic/shape/Isogon';
import Polygon from 'zrender/src/graphic/shape/Polygon';
import { flashlight } from './libs/ShapePoints';
class StationStand extends Group {
constructor({ _code, _type, zlevel, model, state }, style) {
super();
this._code = _code;
this._type = _type;
this.zlevel = zlevel;
this.model = model;
this.state = state;
this.style = style;
this.z = 40;
this.doors = new Group();
this._create(model);
}
_create(model) {
const drict = model.doorLocationType == '01' ? 1 : -1;
this.stationStand = new Rect({
zlevel: this.zlevel,
z: this.z,
shape: {
x: model.position.x - model.width / 2,
y: 0,
width: model.width,
height: model.height
},
style: {
lineWidth: 0,
stroke: this.style.sidelineColor,
fill: this.style.stationStandSpareColor
}
});
/** 站台折返策略*/
const beyond = 4;
const height = 5;
const width = 10;
const offsetx = (model.width - width / 2);
const offsety = (model.height + height + this.style.stationStandDistance) / 2;
this.reentry = new Polygon({
zlevel: this.zlevel,
z: this.z,
shape: {
points: flashlight(model.position.x, model.position.y, drict, width, height, offsetx, offsety, beyond)
},
style: {
lineWidth: 0,
fill: this.style.stationStandNoHumanReentryColor
}
});
this.add(this.reentry);
/** 站台扣车*/
const distance = 0;
const textX = model.position.x + drict * (model.width / 2 + model.textFontSize + distance);
this.text = new Text({
zlevel: this.zlevel,
z: this.z + 2,
position: [0, 0],
style: {
x: textX,
y: 0,
text: 'H',
textAlign: 'middle',
textVerticalAlign: 'top',
fontSize: this.style.stationStandHeadFontSize + 'px ' + this.style.textFontFormat,
textFill: this.style.stationStandCenterDetainTrainColor,
textStroke: this.style.backgroundColor
}
});
this.add(this.text);
/** 停站时间*/
let textLevelT = [0, 0];
if (model.doorLocationType == '02') {
textLevelT = [0, 5];
}
const timeX = model.position.x - drict * (model.width / 2 + this.style.textFontSize + distance);
this.time = new Text({
zlevel: this.zlevel,
z: this.z + 2,
position: textLevelT,
style: {
x: timeX,
y: 0,
text: model.parkingTime,
textFill: this.style.stationStandTimeTextColor,
textAlign: 'middle',
textFont: this.style.textFontSize + 'px ' + this.style.textFontFormat
}
});
this.add(this.time);
/** 区间运行时间*/
let textLevelP = [0, 2];
if (model.doorLocationType == '01') {
textLevelP = [0, 15];
}
const levelX = model.position.x - drict * (model.width / 2 + this.style.textFontSize + distance);
this.level = new Text({
zlevel: this.zlevel,
z: this.z + 2,
position: textLevelP,
style: {
x: levelX,
y: 0,
text: model.intervalRunTime,
textFill: this.style.stationStandTimeTextColor,
textAlign: 'middle',
textFont: this.style.textFontSize + 'px ' + this.style.textFontFormat
}
});
this.add(this.level);
/** 站台紧急关闭*/
this.emergent = new Isogon({
zlevel: this.zlevel,
z: this.z,
shape: {
x: model.position.x,
y: 0,
r: this.style.stationStandDistance / 2,
n: 4
},
style: {
lineWidth: 0,
stroke: this.style.stationStandEmergentCloseColor,
fill: this.style.stationStandEmergentCloseColor
}
});
this.doors.add(this.emergent);
/** 屏蔽门*/
const padding = 0.1;
this.safeDoorL = new Rect({
zlevel: this.zlevel,
z: this.z,
shape: {
x: model.position.x - model.width / 2 - padding,
y: model.position.y,
width: model.width / 4 + padding,
height: this.style.statonStandSafeHeight
},
style: {
lineWidth: 0,
stroke: this.style.stationStandDoorDefaultColor,
fill: this.style.stationStandDoorDefaultColor
}
});
this.safeDoorC = new Rect({
zlevel: this.zlevel,
z: this.z + 1,
shape: {
x: model.position.x - model.width / 4 - padding,
y: model.position.y,
width: model.width / 2 + padding * 2,
height: this.style.statonStandSafeHeight
},
style: {
lineWidth: 0,
stroke: this.style.stationStandDoorDefaultColor,
fill: this.style.stationStandDoorDefaultColor
}
});
this.safeDoorR = new Rect({
zlevel: this.zlevel,
z: this.z,
shape: {
x: model.position.x + model.width / 4,
y: model.position.y,
width: model.width / 4 + padding,
height: this.style.statonStandSafeHeight
},
style: {
lineWidth: 0,
stroke: this.style.stationStandDoorDefaultColor,
fill: this.style.stationStandDoorDefaultColor
}
});
this.setHasSafeDoor(model.hasDoor);
this.setDrict(model.doorLocationType);
this.setVisible(model.visible);
this.setState(model);
}
setDrict(doorLocationType) {
const model = this.model;
const style = this.style;
if (doorLocationType === '01') {
const distance = model.position.y + style.stationStandDistance + style.statonStandSafeHeight;
this.text.setStyle('y', distance + model.height / 2 - style.stationStandHeadFontSize / 2);
this.time.setStyle('y', distance + model.height - style.textFontSize);
this.level.setStyle('y', distance - model.height + style.textFontSize / 1.2);
this.emergent.setShape('y', distance - style.stationStandDistance / 2);
this.stationStand.setShape('y', distance);
} else {
const distance = model.position.y - style.stationStandDistance;
this.text.setStyle('y', distance - model.height / 2 - style.stationStandHeadFontSize / 2);
this.time.setStyle('y', distance - model.height + style.textFontSize);
this.level.setStyle('y', distance - model.height - style.textFontSize / 2);
this.emergent.setShape('y', distance + style.stationStandDistance / 2);
this.stationStand.setShape('y', distance - model.height);
}
this.add(this.doors);
this.add(this.stationStand);
const rect = this.stationStand.getBoundingRect();
rect.union(this.doors.getBoundingRect());
this.standBorder = new Rect({
zlevel: this.model.zlevel,
silent: true,
z: this.z - 1,
shape: rect,
style: {
lineDash: [3, 3],
stroke: style.borderColor,
fill: style.transparentColor
}
});
this.add(this.standBorder);
}
setHasSafeDoor(hasDoor) {
if (hasDoor) {
this.doors.add(this.safeDoorL);
this.doors.add(this.safeDoorC);
this.doors.add(this.safeDoorR);
} else {
this.doors.remove(this.safeDoorL);
this.doors.remove(this.safeDoorC);
this.doors.remove(this.safeDoorR);
}
}
setVisible(visible) {
if (visible) {
this.eachChild((it) => {
it.show();
});
} else {
this.eachChild((it) => {
it.hide();
});
}
}
/** 恢复初始状态*/
recover() {
this.time.hide();
this.level.hide();
this.text.hide();
this.emergent.hide();
this.reentry.hide();
if (this.model.visible) { this.safeDoorC.show(); }
this.safeDoorL.setStyle('fill', this.style.stationStandDoorDefaultColor);
this.safeDoorC.setStyle('fill', this.style.stationStandDoorDefaultColor);
this.safeDoorR.setStyle('fill', this.style.stationStandDoorDefaultColor);
}
/** 空闲*/
spare() {
this.stationStand.setStyle('fill', this.style.stationStandSpareColor);
}
/** 列车停站*/
stop() {
this.stationStand.setStyle('fill', this.style.stationStandStopColor);
}
/** 指定列车跳站*/
designatedJumpStop() {
this.stationStand.setStyle('fill', this.style.stationStandDesignatedJumpStopColor);
}
/** 站台紧急关闭*/
emergentClose() {
this.stationStand.setStyle('fill', this.style.stationStandSpareColor);
this.emergent.show();
}
/** 未设置跳停*/
unJumpStop() {
}
/** 站台跳停*/
jumpStop() {
this.stationStand.setStyle('fill', this.style.stationStandJumpStopColor);
}
/** 未设置扣车*/
unDetainTrain() {
this.text.hide();
}
/** 车站扣车*/
standDetainTrain() {
this.text.show();
this.text.setStyle('textFill', this.style.stationStandDetainTrainTextColor);
}
/** 中心扣车*/
centerDetainTrain() {
this.text.show();
this.text.setStyle('textFill', this.style.stationStandCenterDetainTrainColor);
}
/** 中心+车站扣车*/
standAndCenterDetainTrain() {
this.text.show();
}
/** 人工设置停战时间*/
setManuallyArmisticeTime(val) {
this.time.show();
this.time.attr({
style: {
text: val
}
});
}
/** 人工设置运行等级*/
setManuallyOperationLevel(val) {
this.level.show();
this.level.attr({
style: {
text: val
}
});
}
/** 开门*/
openDoor() {
this.safeDoorC.hide();
}
/** 关门*/
closeDoor() {
if (this.model.model.visible) { this.safeDoorC.show(); }
}
/** 屏蔽门正常*/
doorNormal() {
this.safeDoorL.setStyle('fill', this.style.stationStandDoorDefaultColor);
this.safeDoorC.setStyle('fill', this.style.stationStandDoorDefaultColor);
this.safeDoorR.setStyle('fill', this.style.stationStandDoorDefaultColor);
}
/** 屏蔽门故障*/
doorFault() {
this.safeDoorL.setStyle('fill', this.style.stationStandSplitDoorColor);
this.safeDoorC.setStyle('fill', this.style.stationStandSplitDoorColor);
this.safeDoorR.setStyle('fill', this.style.stationStandSplitDoorColor);
}
/** 屏蔽门切除*/
doorSplit() {
this.safeDoorL.setStyle('fill', this.style.stationStandSplitDoorColor);
this.safeDoorC.setStyle('fill', this.style.stationStandSplitDoorColor);
this.safeDoorR.setStyle('fill', this.style.stationStandSplitDoorColor);
}
/** 无折返(默认)*/
noReentry() {
this.reentry.hide();
}
/** 无人折返*/
noHumanReentry() {
this.reentry.show();
this.reentry.setStyle('fill', this.style.stationStandNoHumanReentryColor);
}
/** 自动换端*/
autoChangeEnds() {
this.reentry.show();
this.reentry.setStyle('fill', this.style.stationStandAutoChangeEndsColor);
}
setState(model) {
this.recover();
switch (model.status) {
case '01': /** 空闲*/
this.spare();
break;
case '02': /** 列车停站*/
this.stop();
break;
case '03': /** 站台紧急关闭*/
this.emergentClose();
break;
}
if (Number(model.parkingTime) >= 0) {
this.setManuallyArmisticeTime(model.parkingTime);
}
if (Number(model.intervalRunTime) > 0) {
this.setManuallyOperationLevel(model.intervalRunTime);
}
/** 设置跳停*/
if (model.status == '01') {
switch (model.jumpStopStatus) {
case '01': /** 未设置跳停*/
this.unJumpStop();
break;
case '02': /** 指定站台跳停*/
this.designatedJumpStop();
break;
case '03': /** 站台全部跳停*/
this.jumpStop();
break;
}
}
/** 设置扣车*/
switch (model.holdStatus) {
case '01': /** 未设置扣车*/
this.unDetainTrain();
break;
case '02': /** 车站扣车*/
this.standDetainTrain();
break;
case '03': /** 中心扣车*/
this.centerDetainTrain();
break;
case '04': /** 中心+车站扣车*/
this.standAndCenterDetainTrain();
break;
}
/** 设置屏蔽门开关*/
switch (model.screenDoorOpenStatus) {
case '01':
this.closeDoor(); /** 关门*/
break;
case '02':
this.openDoor(); /** 开门*/
break;
}
/** 设置屏蔽门状态*/
switch (model.screenDoorStatus) {
case '01':
this.doorNormal(); /** 正常*/
break;
case '02':
this.doorFault(); /** 故障*/
break;
case '03':
this.doorSplit(); /** 切除*/
}
/** 设置折返策略*/
switch (model.reentryStrategy) {
case '04': /** 默认*/
case '01':
this.noReentry(); /** 无折返策略*/
break;
case '02':
this.noHumanReentry(); /** 无人折返*/
break;
case '03':
this.autoChangeEnds(); /** 自动换端*/
break;
}
}
getShapeTipPoint() {
const rect = this.stationStand.getBoundingRect();
if (rect) {
return {
x: rect.x + rect.width / 2,
y: rect.y
};
}
return null;
}
}
export default StationStand;

View File

@ -0,0 +1,80 @@
import Group from 'zrender/src/container/Group';
import Rect from 'zrender/src/graphic/shape/Rect';
class ESafeDoor extends Group {
constructor(model) {
super();
this.model = model;
this._create();
}
_create() {
const model = this.model;
const style = this.model.style;
const padding = 0.1;
this.safeL = new Rect({
zlevel: model.zlevel,
z: model.z,
shape: {
x: model.x - model.width / 2 - padding,
y: model.y,
width: model.width / 4 + padding,
height: model.height
},
style: {
lineWidth: 0,
stroke: style.StationStand.standDoorDefaultColor,
fill: style.StationStand.standDoorDefaultColor
}
});
this.safeC = new Rect({
zlevel: model.zlevel,
z: model.z + 1,
shape: {
x: model.x - model.width / 4 - padding,
y: model.y,
width: model.width / 2 + padding * 2,
height: model.height
},
style: {
lineWidth: 0,
stroke: style.StationStand.standDoorDefaultColor,
fill: style.StationStand.standDoorDefaultColor
}
});
this.safeR = new Rect({
zlevel: model.zlevel,
z: model.z,
shape: {
x: model.x + model.width / 4,
y: model.y,
width: model.width / 4 + padding,
height: model.height
},
style: {
lineWidth: 0,
stroke: style.StationStand.standDoorDefaultColor,
fill: style.StationStand.standDoorDefaultColor
}
});
this.add(this.safeL);
this.add(this.safeC);
this.add(this.safeR);
}
hasDoor(show) {
show ? this.safeR.show() : this.safeC.hide();
}
setColor(color) {
this.safeL.setStyle('fill', color);
this.safeC.setStyle('fill', color);
this.safeR.setStyle('fill', color);
}
}
export default ESafeDoor;

View File

@ -0,0 +1,39 @@
import Group from 'zrender/src/container/Group';
import Isogon from 'zrender/src/graphic/shape/Isogon';
class ESafeEmergent extends Group {
constructor(model) {
super();
this.model = model;
this._create();
}
_create() {
const model = this.model;
const style = this.model.style;
this.emergent = new Isogon({
zlevel: model.zlevel,
z: model.z,
shape: {
x: model.x,
y: model.y,
r: style.StationStand.standDistance / 2,
n: model.n
},
style: {
lineWidth: 0,
stroke: style.StationStand.standEmergentCloseColor,
fill: style.StationStand.standEmergentCloseColor
}
});
this.add(this.emergent);
}
setVisible(show) {
show ? this.emergent.show(): this.emergent.hide();
}
}
export default ESafeEmergent;

View File

@ -0,0 +1,39 @@
import Group from 'zrender/src/container/Group';
import Rect from 'zrender/src/graphic/shape/Rect';
class ESafeStand extends Group {
constructor(model) {
super();
this.model = model;
this._create();
}
_create() {
const model = this.model;
const style = this.model.style;
this.stand = new Rect({
zlevel: model.zlevel,
z: model.z,
shape: {
x: model.x,
y: model.y,
width: model.width,
height: model.height
},
style: {
lineWidth: 0,
stroke: style.sidelineColor,
fill: style.StationStand.standSpareColor
}
});
this.add(this.stand);
}
setColor(color) {
this.stand.setStyle('fill', color);
}
}
export default ESafeStand;

View File

@ -109,6 +109,53 @@ class Beijing extends defaultSkin {
signalLampBlueColor: '#0070C0'
};
this[deviceType.StationStand] = {
/** 站台和屏蔽门之间的距离*/
standDistance: 9,
/** 站台屏蔽门高度*/
standSafeHeight: 1.6,
/** 站台首端字体大小*/
standHeadFontSize: 9,
/** 站台无人折返*/
standNoHumanReentryColor: '#0F16DA',
/** 站台自动换端*/
standAutoChangeEndsColor: '#0BF400',
/** 站台空闲颜色*/
standSpareColor: '#606060',
/** 站台列车停站颜色*/
standStopColor: '#FEFE00',
/** 站台跳停颜色*/
standJumpStopColor: '#9A99FF',
/** 站台指定列车跳停颜色*/
standDesignatedJumpStopColor: 'lightSkyBlue',
/** 站台紧急关闭颜色*/
standEmergentCloseColor: '#F61107',
/** 停站时间字体颜色*/
standTimeTextColor: '#FFFFFF',
/** 车站扣车颜色*/
standDetainTrainColor: '#E4EF50',
/** 中心扣车颜色*/
standCenterDetainTrainColor: '#FFFFFF',
/** 车站+中心扣车颜色*/
standAndCenterDetainTrainColor: '#F61107',
/** 屏蔽门默认颜色*/
standDoorDefaultColor: '#00FF00',
/** 屏蔽门切除颜色*/
standSplitDoorColor: '#F61107',
/** 车站扣除文字颜色*/
standDetainTrainTextColor: '#E4EF50',
/** 计数器字体颜色*/
stationCounterTextColor: '#FFFFFF',
/** 计数器边框颜色*/
stationCounterBorderColor: '#E4EF50',
/** 延迟解锁倒计时和设备文字之间的距离*/
stationDelayUnlockDistance: 3,
/** 延时解锁字体颜色*/
stationDelayUnlockTextColor: '#FFFFFF',
/** 延迟解锁边框颜色*/
stationDelayUnlockBorderColor: '#FFFFFF'
};
}
}

View File

@ -39,7 +39,7 @@ export default {
stateLoaded() { console.log('stateLoaded'); },
viewUpdate() { console.log('viewUpdate'); },
stateUpdate() { console.log('stateUpdate'); },
optionsUpdate() { console.log('optionsUpdate'); }
// optionsUpdate() { console.log('optionsUpdate'); }
}
});
this.jmap.on('selected', this.selected);
@ -82,10 +82,10 @@ export default {
},
methods: {
selected(e) {
console.log('selected', e, this.jmap);
// console.log('selected', e, this.jmap);
},
contextmenu(e) {
console.log('contextmenu', e);
// console.log('contextmenu', e);
}
}
};