修改道岔状态变化
This commit is contained in:
parent
10cd98fe6f
commit
33442905be
@ -8,6 +8,7 @@ import deviceState from './constant/deviceState';
|
|||||||
import { selectSkinStyle } from './config/deviceStyle';
|
import { selectSkinStyle } from './config/deviceStyle';
|
||||||
import deviceType from './constant/deviceType';
|
import deviceType from './constant/deviceType';
|
||||||
import { parser, deviceFactory, createBoundingRect, calculateDCenter } from './utils/parser';
|
import { parser, deviceFactory, createBoundingRect, calculateDCenter } from './utils/parser';
|
||||||
|
import { lstat } from 'fs';
|
||||||
|
|
||||||
const renderer = 'canvas';
|
const renderer = 'canvas';
|
||||||
const devicePixelRatio = 1;
|
const devicePixelRatio = 1;
|
||||||
@ -166,21 +167,24 @@ class Jlmap {
|
|||||||
if (this.methods.viewUpdate instanceof Function) { this.methods.viewUpdate(list); }
|
if (this.methods.viewUpdate instanceof Function) { this.methods.viewUpdate(list); }
|
||||||
}
|
}
|
||||||
|
|
||||||
pretreatment(list) {
|
// 中间处理
|
||||||
const tempList = [];
|
hookHandle(elem) {
|
||||||
|
// 如果是延时计时,需要保存计数值到全局
|
||||||
list.forEach(elem => {
|
if (elem._type === deviceType.StationCounter) {
|
||||||
// 设置计数器增加
|
let val = '' + elem.val;
|
||||||
if (elem._type === deviceType.StationCounter) {
|
if (val === '0' || !elem.val) {
|
||||||
let val = '' + elem.val;
|
val = elem.val = localStore.get(elem._code) || '0';
|
||||||
if (val === '0' || !elem.val) {
|
|
||||||
val = elem.val = localStore.get(elem._code) || '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
localStore(elem._code, val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置区段层级
|
localStore(elem._code, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 后处理
|
||||||
|
postHandle(list) {
|
||||||
|
list.forEach(elem => {
|
||||||
if (elem._type == deviceType.Switch) {
|
if (elem._type == deviceType.Switch) {
|
||||||
const item = this.mapDevice[elem.code];
|
const item = this.mapDevice[elem.code];
|
||||||
if (item) {
|
if (item) {
|
||||||
@ -188,15 +192,16 @@ class Jlmap {
|
|||||||
const sectionB = this.mapDevice[item.model.sectionBCode];
|
const sectionB = this.mapDevice[item.model.sectionBCode];
|
||||||
const sectionC = this.mapDevice[item.model.sectionCCode];
|
const sectionC = this.mapDevice[item.model.sectionCCode];
|
||||||
if (sectionA && sectionB && sectionC) {
|
if (sectionA && sectionB && sectionC) {
|
||||||
elem.cutOff = sectionA.state.cutOff;
|
item.state['cutOff'] = sectionA.state.cutOff;
|
||||||
elem.sectionAstatus = sectionA.state.status;
|
item.state['sectionAstatus'] = sectionA.state.status;
|
||||||
elem.sectionBstatus = sectionB.state.status;
|
item.state['sectionBstatus'] = sectionB.state.status;
|
||||||
elem.sectionCstatus = sectionC.state.status;
|
item.state['sectionCstatus'] = sectionC.state.status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$painter.update(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置道岔切除
|
|
||||||
if (elem._type == deviceType.Section) {
|
if (elem._type == deviceType.Section) {
|
||||||
const item = this.mapDevice[elem.code];
|
const item = this.mapDevice[elem.code];
|
||||||
if (item) {
|
if (item) {
|
||||||
@ -206,33 +211,34 @@ class Jlmap {
|
|||||||
const sectionB = this.mapDevice[swch.model.sectionBCode];
|
const sectionB = this.mapDevice[swch.model.sectionBCode];
|
||||||
const sectionC = this.mapDevice[swch.model.sectionCCode];
|
const sectionC = this.mapDevice[swch.model.sectionCCode];
|
||||||
if (sectionA && sectionB && sectionC) {
|
if (sectionA && sectionB && sectionC) {
|
||||||
swch.state.sectionAstatus = sectionA.state.status;
|
swch.state['sectionAstatus'] = sectionA.state.status;
|
||||||
swch.state.sectionBstatus = sectionB.state.status;
|
swch.state['sectionBstatus'] = sectionB.state.status;
|
||||||
swch.state.sectionCstatus = sectionC.state.status;
|
swch.state['sectionCstatus'] = sectionC.state.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
tempList.push(swch.state);
|
this.$painter.update(swch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return [...list, ...tempList];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update(list) {
|
update(list) {
|
||||||
this.pretreatment(list).forEach(elem => {
|
(list || []).forEach(elem => {
|
||||||
const code = elem.code;
|
const code = elem.code;
|
||||||
const oDevice = this.mapDevice[code] || {};
|
const oDevice = this.mapDevice[code] || {};
|
||||||
if (elem._dispose) {
|
if (elem._dispose) {
|
||||||
this.$painter.delete(oDevice);
|
this.$painter.delete(oDevice);
|
||||||
} else {
|
} else {
|
||||||
const state = Object.assign(oDevice.state || {}, elem);
|
const state = Object.assign(oDevice.state || {}, this.hookHandle(elem));
|
||||||
const nDevice = Object.assign(oDevice, { state });
|
const nDevice = Object.assign(oDevice, { state });
|
||||||
this.$painter.update(nDevice);
|
this.$painter.update(nDevice);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 状态后处理
|
||||||
|
this.postHandle(list);
|
||||||
|
|
||||||
if (this.methods.stateUpdate instanceof Function) { this.methods.stateUpdate(list); }
|
if (this.methods.stateUpdate instanceof Function) { this.methods.stateUpdate(list); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ export default class Section extends Group {
|
|||||||
this._type = _type;
|
this._type = _type;
|
||||||
this.zlevel = zlevel;
|
this.zlevel = zlevel;
|
||||||
this.z = 5 + parseInt(model.layer || 0);
|
this.z = 5 + parseInt(model.layer || 0);
|
||||||
console.log(model.layer);
|
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.style = style;
|
this.style = style;
|
||||||
@ -165,7 +164,7 @@ export default class Section extends Group {
|
|||||||
const fontSize = model.type == '02' ? style.Section.text.fontSize + 2: style.Section.text.fontSize;
|
const fontSize = model.type == '02' ? style.Section.text.fontSize + 2: style.Section.text.fontSize;
|
||||||
this.sectionText = new ETextName({
|
this.sectionText = new ETextName({
|
||||||
zlevel: this.zlevel,
|
zlevel: this.zlevel,
|
||||||
z: this.z + 6,
|
z: this.z + 2,
|
||||||
style: this.style,
|
style: this.style,
|
||||||
silent: false,
|
silent: false,
|
||||||
x: tempx,
|
x: tempx,
|
||||||
@ -195,7 +194,7 @@ export default class Section extends Group {
|
|||||||
// 创建站台轨名称
|
// 创建站台轨名称
|
||||||
this.standTrackText = new ETextName({
|
this.standTrackText = new ETextName({
|
||||||
zlevel: this.zlevel,
|
zlevel: this.zlevel,
|
||||||
z: 6,
|
z: this.z + 2,
|
||||||
x: tempx + model.standTrackNamePosition.x,
|
x: tempx + model.standTrackNamePosition.x,
|
||||||
y: tempy + model.standTrackNamePosition.y,
|
y: tempy + model.standTrackNamePosition.y,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
@ -216,7 +215,7 @@ export default class Section extends Group {
|
|||||||
// 创建折返轨名称
|
// 创建折返轨名称
|
||||||
this.reentryTrackText = new ETextName({
|
this.reentryTrackText = new ETextName({
|
||||||
zlevel: this.zlevel,
|
zlevel: this.zlevel,
|
||||||
z: 6,
|
z: this.z + 2,
|
||||||
x: x + model.reentryTrackNamePosition.x,
|
x: x + model.reentryTrackNamePosition.x,
|
||||||
y: y + model.reentryTrackNamePosition.y + style.nameDistance + style.Section.text.fontSize,
|
y: y + model.reentryTrackNamePosition.y + style.nameDistance + style.Section.text.fontSize,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
@ -237,7 +236,7 @@ export default class Section extends Group {
|
|||||||
// 转换轨名称
|
// 转换轨名称
|
||||||
this.transferTrackText = new ETextName({
|
this.transferTrackText = new ETextName({
|
||||||
zlevel: this.zlevel,
|
zlevel: this.zlevel,
|
||||||
z: 6,
|
z: this.z + 2,
|
||||||
x: x + model.transferTrackNamePosition.x,
|
x: x + model.transferTrackNamePosition.x,
|
||||||
y: y + model.transferTrackNamePosition.y + style.nameDistance + style.Section.text.fontSize * 2,
|
y: y + model.transferTrackNamePosition.y + style.nameDistance + style.Section.text.fontSize * 2,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
@ -258,7 +257,7 @@ export default class Section extends Group {
|
|||||||
// 转换轨名称
|
// 转换轨名称
|
||||||
this.destinationText = new ETextName({
|
this.destinationText = new ETextName({
|
||||||
zlevel: this.zlevel,
|
zlevel: this.zlevel,
|
||||||
z: 6,
|
z: this.z + 2,
|
||||||
x: x + model.destinationCodePoint.x,
|
x: x + model.destinationCodePoint.x,
|
||||||
y: y + model.destinationCodePoint.y,
|
y: y + model.destinationCodePoint.y,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
|
@ -22,7 +22,7 @@ class Signal extends Group {
|
|||||||
this.count = parseInt(model.lampPositionType);
|
this.count = parseInt(model.lampPositionType);
|
||||||
this.lamps = new Array(this.count);
|
this.lamps = new Array(this.count);
|
||||||
this.zlevel = zlevel;
|
this.zlevel = zlevel;
|
||||||
this.z = 1;
|
this.z = 7;
|
||||||
this.create();
|
this.create();
|
||||||
this.transformRotation(this);
|
this.transformRotation(this);
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
|
@ -29,7 +29,7 @@ class ESwLnversion extends Group {
|
|||||||
|
|
||||||
this.section = new Polygon({
|
this.section = new Polygon({
|
||||||
zlevel: model.zlevel,
|
zlevel: model.zlevel,
|
||||||
z: model.z,
|
z: model.z + 1,
|
||||||
shape: {
|
shape: {
|
||||||
points: model.sectionPoints
|
points: model.sectionPoints
|
||||||
},
|
},
|
||||||
|
@ -185,6 +185,7 @@ export default class Switch extends Group {
|
|||||||
this.releaseBackground.hide();
|
this.releaseBackground.hide();
|
||||||
|
|
||||||
this.setHasTextBorder(0);
|
this.setHasTextBorder(0);
|
||||||
|
|
||||||
switch (this.state.locateType) {
|
switch (this.state.locateType) {
|
||||||
case '01':
|
case '01':
|
||||||
this.setTextColor(this.style.Switch.text.switchTextLocateColor);
|
this.setTextColor(this.style.Switch.text.switchTextLocateColor);
|
||||||
@ -212,6 +213,7 @@ export default class Switch extends Group {
|
|||||||
this.setSwitchCoreInvisible(true);
|
this.setSwitchCoreInvisible(true);
|
||||||
this.locShelter.hide();
|
this.locShelter.hide();
|
||||||
this.relocShelter.show();
|
this.relocShelter.show();
|
||||||
|
this.setSectionState(this.relocShelter.getSection(), 'fill', this.state.sectionAstatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 失去*/
|
/** 失去*/
|
||||||
@ -261,7 +263,6 @@ export default class Switch extends Group {
|
|||||||
switch (this.model.locateType) {
|
switch (this.model.locateType) {
|
||||||
case '01':
|
case '01':
|
||||||
this.releaseBackground.hide();
|
this.releaseBackground.hide();
|
||||||
this.setSectionState(this.relocShelter.getSection(), 'stroke', this.state.sectionAstatus);
|
|
||||||
break;
|
break;
|
||||||
case '02':
|
case '02':
|
||||||
this.relocShelter.getSection().animateStyle(true)
|
this.relocShelter.getSection().animateStyle(true)
|
||||||
@ -271,48 +272,46 @@ export default class Switch extends Group {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setSectionState(section, styleKey, state) {
|
setSectionState(section, style, state) {
|
||||||
if (section) {
|
if (section) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case '00': break;
|
case '00': break;
|
||||||
case '01': /** 空闲*/
|
case '01': /** 空闲*/
|
||||||
section.setStyle(styleKey, this.style.Section.line.spareColor);
|
section.setStyle(style, this.style.Section.line.spareColor);
|
||||||
break;
|
break;
|
||||||
case '02': /** 通信车占用*/
|
case '02': /** 通信车占用*/
|
||||||
section.setStyle(styleKey, this.style.Section.line.communicationOccupiedColor);
|
section.setStyle(style, this.style.Section.line.communicationOccupiedColor);
|
||||||
break;
|
break;
|
||||||
case '03': /** 非通信车占用*/
|
case '03': /** 非通信车占用*/
|
||||||
section.setStyle(styleKey, this.style.Section.line.unCommunicationOccupiedColor);
|
section.setStyle(style, this.style.Section.line.unCommunicationOccupiedColor);
|
||||||
break;
|
break;
|
||||||
case '04': /** 进路锁闭*/
|
case '04': /** 进路锁闭*/
|
||||||
section.setStyle(styleKey, this.style.Section.line.routeLockColor);
|
section.setStyle(style, this.style.Section.line.routeLockColor);
|
||||||
break;
|
break;
|
||||||
case '05': /** 故障锁闭*/
|
case '05': /** 故障锁闭*/
|
||||||
section.setStyle(styleKey, this.style.Section.line.faultLockColor);
|
section.setStyle(style, this.style.Section.line.faultLockColor);
|
||||||
break;
|
break;
|
||||||
case '06': /** 封锁*/
|
case '06': /** 封锁*/
|
||||||
section.setStyle(styleKey, this.style.Section.line.blockColor);
|
section.setStyle(style, this.style.Section.line.blockColor);
|
||||||
break;
|
break;
|
||||||
case '07': /** ATC切除*/
|
case '07': /** ATC切除*/
|
||||||
section.setStyle(styleKey, this.style.Section.line.atcExcisionColor);
|
section.setStyle(style, this.style.Section.line.atcExcisionColor);
|
||||||
break;
|
break;
|
||||||
case '08': /** ATS切除*/
|
case '08': /** ATS切除*/
|
||||||
section.setStyle(styleKey, this.style.Section.line.atsExcisionColor);
|
section.setStyle(style, this.style.Section.line.atsExcisionColor);
|
||||||
section.animateStyle(true)
|
section.animateStyle(true)
|
||||||
.when(1000, { fill: this.style.backgroundColor })
|
.when(1000, { fill: this.style.backgroundColor })
|
||||||
.when(2000, { fill: this.style.Section.line.atsExcisionColor })
|
.when(2000, { fill: this.style.Section.line.atsExcisionColor })
|
||||||
.start();
|
.start();
|
||||||
break;
|
break;
|
||||||
case '09': /** 进路延续保护 */
|
case '09': /** 进路延续保护 */
|
||||||
section.setStyle(styleKey, this.style.Section.line.protectiveLockColor);
|
section.setStyle(style, this.style.Section.line.protectiveLockColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setLocateType(state) {
|
setLocateType(state) {
|
||||||
console.log(this.state.sectionCstatus);
|
|
||||||
this.setSectionState(this.relocShelter.getSection(), 'fill', this.state.sectionCstatus);
|
|
||||||
switch (state.locateType) {
|
switch (state.locateType) {
|
||||||
case '01':
|
case '01':
|
||||||
this.setLocationAction(); /** 定位*/
|
this.setLocationAction(); /** 定位*/
|
||||||
|
@ -108,9 +108,9 @@ export function parser(data, jmap) {
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
zrUtil.each(data.switchList || [], elem => {
|
zrUtil.each(data.switchList || [], elem => {
|
||||||
const cnodeSection = elem['sectionA'] = mapDevice[elem.sectionACode];
|
const cnodeSection = mapDevice[elem.sectionACode];
|
||||||
const lnodeSection = elem['sectionB'] = mapDevice[elem.sectionBCode];
|
const lnodeSection = mapDevice[elem.sectionBCode];
|
||||||
const rnodeSection = elem['sectionC'] = mapDevice[elem.sectionCCode];
|
const rnodeSection = mapDevice[elem.sectionCCode];
|
||||||
|
|
||||||
cnodeSection.model['switch'] = lnodeSection.model['switch'] = rnodeSection.model['switch'] = elem;
|
cnodeSection.model['switch'] = lnodeSection.model['switch'] = rnodeSection.model['switch'] = elem;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user