2020-03-19 16:17:34 +08:00
|
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
import EControl from '../element/EControl';
|
|
|
|
import EMouse from './EMouse';
|
|
|
|
import {isShowThePrdType} from '../../utils/handlePath';
|
2020-03-24 16:35:09 +08:00
|
|
|
import deviceType from '../../constant/deviceType';
|
2020-04-14 15:45:13 +08:00
|
|
|
import ELampFilament from './ELampFilament';
|
|
|
|
import EControlSwitch from './EControlSwitch';
|
|
|
|
import EFoldbackMode from './EFoldbackMode';
|
|
|
|
import EDeviceStatus from './EDeviceStatus';
|
|
|
|
import EModeStatus from './EModeStatus';
|
|
|
|
import EUnmanned from './EUnmanned';
|
|
|
|
import EAxle from './EAxle';
|
2020-03-19 16:17:34 +08:00
|
|
|
|
2020-03-24 16:35:09 +08:00
|
|
|
export default class SaidLamp extends Group {
|
2020-03-19 16:17:34 +08:00
|
|
|
constructor(model, style) {
|
|
|
|
super();
|
|
|
|
this.z = 20;
|
|
|
|
this._code = model.code;
|
|
|
|
this._type = model._type;
|
|
|
|
this.zlevel = model.zlevel;
|
|
|
|
this.model = model;
|
|
|
|
this.style = style;
|
|
|
|
this.deviceStyle = style[model._type];
|
2020-04-22 17:12:29 +08:00
|
|
|
if (this.deviceStyle) {
|
|
|
|
this.isShowShape = true;
|
|
|
|
if (isShowThePrdType(model.prdType, this.deviceStyle.displayCondition) || model.previewOrMapDraw) {
|
|
|
|
this.create();
|
|
|
|
this.createMouseEvent();
|
|
|
|
this.setState(model);
|
|
|
|
}
|
|
|
|
if (model.previewOrMapDraw) {
|
|
|
|
this.setShowMode();
|
|
|
|
}
|
2020-03-19 16:17:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
create() {
|
|
|
|
const model = this.model;
|
2020-04-22 17:12:29 +08:00
|
|
|
const lampDevice = ['LeuControl', 'IntersiteControl', 'CenterCommunication', 'AtsControl', 'LocalControl', 'ChainControl', 'Maintain', 'PowerSupply', 'MaintenanceLamps', 'ZcCommunication', 'SwitchFault'];
|
2020-04-14 15:45:13 +08:00
|
|
|
if (lampDevice.includes(this._type)) {
|
|
|
|
this.control = new EControl({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
|
|
|
arc: {
|
|
|
|
shape: {
|
|
|
|
cx: model.position.x,
|
|
|
|
cy: model.position.y,
|
|
|
|
r: this.deviceStyle.lamp.radiusR
|
|
|
|
},
|
|
|
|
subType: 'Control',
|
2020-04-22 17:12:29 +08:00
|
|
|
lineWidth: this.deviceStyle.lamp.lineWidth || 0,
|
|
|
|
fill: this.deviceStyle.lamp.controlColor,
|
|
|
|
stroke: this.deviceStyle.lamp.strokeColor
|
2020-03-19 16:17:34 +08:00
|
|
|
},
|
2020-04-14 15:45:13 +08:00
|
|
|
text: {
|
|
|
|
position: [0, 0],
|
|
|
|
x: model.position.x,
|
|
|
|
y: model.position.y + this.deviceStyle.lamp.radiusR + this.deviceStyle.text.distance,
|
|
|
|
fontWeight: this.deviceStyle.text.fontWeight,
|
|
|
|
fontSize: this.deviceStyle.text.fontSize,
|
|
|
|
fontFamily: this.style.fontFamily,
|
|
|
|
text: model.name,
|
|
|
|
textFill: '#fff',
|
|
|
|
textAlign: 'middle',
|
|
|
|
textVerticalAlign: 'top'
|
|
|
|
},
|
|
|
|
style: this.style
|
|
|
|
});
|
|
|
|
this.add(this.control);
|
|
|
|
} else if (this._type === 'LampFilament') {
|
|
|
|
this.control = new ELampFilament({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
2020-03-19 16:17:34 +08:00
|
|
|
x: model.position.x,
|
2020-04-14 15:45:13 +08:00
|
|
|
y: model.position.y,
|
|
|
|
_subType: 'LampFilament',
|
|
|
|
width: this.deviceStyle.width,
|
|
|
|
fill: this.deviceStyle.defaultColor
|
|
|
|
});
|
|
|
|
this.add(this.control);
|
|
|
|
} else if (this._type === 'ControlSwitch') {
|
|
|
|
this.control = new EControlSwitch({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
|
|
|
x: model.position.x,
|
|
|
|
y: model.position.y,
|
|
|
|
_subType: 'ControlSwitch',
|
|
|
|
width: this.deviceStyle.width,
|
|
|
|
fill: this.deviceStyle.defaultColor
|
|
|
|
});
|
|
|
|
this.add(this.control);
|
|
|
|
} else if (this._type === 'FaultStatusGroup') {
|
|
|
|
this.control = new EDeviceStatus({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
|
|
|
x: model.position.x,
|
|
|
|
y: model.position.y,
|
2020-04-20 17:10:50 +08:00
|
|
|
mfNum: model.mfNum,
|
|
|
|
pfNum: model.pfNum,
|
2020-04-14 15:45:13 +08:00
|
|
|
style: this.style
|
|
|
|
});
|
|
|
|
this.add(this.control);
|
|
|
|
} else if (this._type === 'ReturnModeGroup') {
|
|
|
|
this.control = new EFoldbackMode({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
|
|
|
x: model.position.x,
|
|
|
|
y: model.position.y,
|
|
|
|
width: this.deviceStyle.rectWidth,
|
|
|
|
style: this.style
|
|
|
|
});
|
|
|
|
this.add(this.control);
|
|
|
|
} else if (this._type === 'ModeStatusGroup') {
|
|
|
|
this.control = new EModeStatus({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
|
|
|
x: model.position.x,
|
|
|
|
y: model.position.y,
|
|
|
|
style: this.style
|
|
|
|
});
|
|
|
|
this.add(this.control);
|
|
|
|
} else if (this._type === 'Axle') {
|
|
|
|
this.control = new EAxle({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
|
|
|
x: model.position.x,
|
|
|
|
y: model.position.y,
|
|
|
|
style: this.style
|
|
|
|
});
|
|
|
|
this.add(this.control);
|
|
|
|
} else if (this._type === 'NoOneReturn') {
|
|
|
|
if (this.deviceStyle.showShape === 'Unmanned') {
|
|
|
|
this.control = new EUnmanned({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
2020-04-17 15:59:50 +08:00
|
|
|
x: model.position.x,
|
|
|
|
y: model.position.y,
|
2020-04-14 15:45:13 +08:00
|
|
|
_subType: 'Unmanned',
|
|
|
|
width: this.style.NoOneReturn.width,
|
|
|
|
fill: this.style.NoOneReturn.defaultColor
|
|
|
|
});
|
|
|
|
this.add(this.control);
|
|
|
|
} else {
|
|
|
|
this.control = new EControl({
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
|
|
|
arc: {
|
|
|
|
shape: {
|
|
|
|
cx: model.position.x,
|
|
|
|
cy: model.position.y,
|
|
|
|
r: this.deviceStyle.lamp.radiusR
|
|
|
|
},
|
|
|
|
subType: 'Control',
|
|
|
|
lineWidth: 0,
|
|
|
|
fill: this.deviceStyle.lamp.controlColor
|
|
|
|
},
|
|
|
|
text: {
|
|
|
|
position: [0, 0],
|
|
|
|
x: model.position.x,
|
|
|
|
y: model.position.y + this.deviceStyle.lamp.radiusR + this.deviceStyle.text.distance,
|
|
|
|
fontWeight: this.deviceStyle.text.fontWeight,
|
|
|
|
fontSize: this.deviceStyle.text.fontSize,
|
|
|
|
fontFamily: this.style.fontFamily,
|
|
|
|
text: model.name,
|
|
|
|
textFill: '#fff',
|
|
|
|
textAlign: 'middle',
|
|
|
|
textVerticalAlign: 'top'
|
|
|
|
},
|
|
|
|
style: this.style
|
|
|
|
});
|
|
|
|
this.add(this.control);
|
|
|
|
}
|
|
|
|
}
|
2020-03-19 16:17:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 设置状态
|
|
|
|
setState(model) {
|
|
|
|
if (!this.isShowShape) return;
|
2020-03-24 16:35:09 +08:00
|
|
|
if (model._type === deviceType.PowerSupply && model.name.includes('2')) {
|
2020-03-24 16:50:09 +08:00
|
|
|
this.control && this.control.setControlColor(this.deviceStyle.lamp.offColor);
|
|
|
|
this.control && this.control.setControlStroke(this.deviceStyle.lamp.strokeColor, 1);
|
2020-03-24 16:35:09 +08:00
|
|
|
} else if ((model._type === deviceType.AtsControl || model._type === deviceType.LocalControl || model._type === deviceType.ChainControl) && model.name.includes('B')) {
|
2020-03-24 16:50:09 +08:00
|
|
|
this.control && this.control.setControlColor(this.deviceStyle.lamp.offColor);
|
2020-03-24 16:35:09 +08:00
|
|
|
}
|
2020-03-19 16:17:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
createMouseEvent() {
|
|
|
|
if (this.deviceStyle.mouseOverStyle) {
|
|
|
|
this.mouseEvent = new EMouse(this);
|
|
|
|
this.add(this.mouseEvent);
|
|
|
|
this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
|
|
|
|
this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getShapeTipPoint() {
|
|
|
|
if (this.control) {
|
|
|
|
var distance = 2;
|
|
|
|
var rect = this.control.getBoundingRect();
|
|
|
|
return {
|
|
|
|
x: rect.x + rect.width / 2,
|
|
|
|
y: rect.y - distance
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
setShowMode() {
|
|
|
|
const showMode = this.model.showMode;
|
2020-04-22 17:12:29 +08:00
|
|
|
if (this.deviceStyle) {
|
|
|
|
const showConditions = this.deviceStyle.displayCondition;
|
|
|
|
if (showConditions === '01' || showMode === showConditions) {
|
|
|
|
this.control && this.control.show();
|
|
|
|
} else {
|
|
|
|
this.control && this.control.hide();
|
|
|
|
}
|
2020-03-19 16:17:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
setShowStation(stationCode) {
|
|
|
|
if (!stationCode || this.model.stationCode === stationCode) {
|
|
|
|
this.control && this.control.show();
|
|
|
|
this.isShowShape = true;
|
|
|
|
this.setState(this.model);
|
|
|
|
} else {
|
|
|
|
this.control && this.control.hide();
|
|
|
|
this.isShowShape = false;
|
|
|
|
}
|
|
|
|
}
|
2020-06-04 11:32:49 +08:00
|
|
|
setControlColor(color, flag) {
|
|
|
|
this.control && this.control.getControl().stopAnimation(false);
|
2020-05-29 17:32:20 +08:00
|
|
|
this.control && this.control.setControlColor(color);
|
2020-06-04 11:32:49 +08:00
|
|
|
if (flag) {
|
|
|
|
this.control && this.control.getControl().animateStyle(true)
|
|
|
|
.when(0, { fill: this.style.backgroundColor })
|
|
|
|
.when(1000, { fill: color })
|
|
|
|
.when(2000, { fill: this.style.backgroundColor })
|
|
|
|
.start();
|
|
|
|
}
|
|
|
|
|
2020-05-29 17:32:20 +08:00
|
|
|
}
|
2020-03-19 16:17:34 +08:00
|
|
|
}
|