设置数据更新中间层
This commit is contained in:
parent
e5adb93315
commit
4ca7af6b0a
@ -1,81 +1,86 @@
|
||||
import deviceType from './deviceType';
|
||||
import { deepAssign } from '@/utils/index';
|
||||
|
||||
const stateTransition = {};
|
||||
|
||||
stateTransition[deviceType.Section] = {
|
||||
/** 区段状态*/
|
||||
blockade: false, // 是否封锁
|
||||
routeLock: false, // 是否进路锁闭
|
||||
overlapLock: false, // 进路延续保护锁闭
|
||||
ctOccupied: false, // 通信车占用
|
||||
nctOccupied: false, // 非通信车占用
|
||||
/** 是否故障*/
|
||||
fault: false /** 非故障*/
|
||||
// 所有默认状态在这里都要有 用来转换后台发送的数据状态
|
||||
class Status {
|
||||
// el是宿主元素
|
||||
// vm是KVue实例
|
||||
constructor(device) {
|
||||
// 保存kVue实例
|
||||
this.statusObj = {};
|
||||
if (device && device._type) {
|
||||
// 执行编译
|
||||
this['handle' + device._type](device);
|
||||
}
|
||||
}
|
||||
handleStationStand(device) {
|
||||
this.statusObj = {
|
||||
free: device.free, // 站台空闲
|
||||
trainParking: device.trainParking, // 列车停站
|
||||
emergencyClosed: device.emergencyClosed, // 站台紧急关闭
|
||||
stationHoldTrain: device.stationHoldTrain, // 站台是否扣车
|
||||
centerHoldTrain: device.centerHoldTrain, // 中心是否扣车 true 扣车 false 非扣车状态
|
||||
allSkip: device.allSkip, // 是否全部跳停
|
||||
assignSkip: device.assignSkip, // 是否指定跳停
|
||||
runLevelTime: device.runLevelTime, // 区间运行时间 自动为 0
|
||||
parkingTime: device.parkingTime, // 站台停车时间 自动为0
|
||||
fault: device.fault /** 非故障*/
|
||||
};
|
||||
|
||||
stateTransition[deviceType.Switch] = {
|
||||
singleLock: 1, // 是否单锁
|
||||
blockade: 0, // 是否封锁
|
||||
routeLock: 0, // 是否进路锁闭
|
||||
overlapLock: 0, // 是否进路延续保护锁闭
|
||||
normalPosition: 1, // 是否定位
|
||||
reversePosition: 0, // 是否反位
|
||||
/** 是否故障*/
|
||||
fault: false /** 非故障*/
|
||||
// /** 是否切除*/
|
||||
// cutOff: {
|
||||
// Default: false /** 是否切除*/
|
||||
// }
|
||||
}
|
||||
handleSection(device) {
|
||||
this.statusObj = {
|
||||
blockade: device.blockade, // 是否封锁
|
||||
routeLock: device.routeLock, // 是否进路锁闭
|
||||
overlapLock: device.overlapLock, // 进路延续保护锁闭
|
||||
ctOccupied: device.ctOccupied, // 通信车占用
|
||||
nctOccupied: device.nctOccupied, // 非通信车占用
|
||||
fault: device.fault /** 非故障*/
|
||||
};
|
||||
|
||||
stateTransition[deviceType.Signal] = {
|
||||
/** 是否故障*/
|
||||
fault: false /** 非故障*/
|
||||
}
|
||||
handleSwitch(device) {
|
||||
this.statusObj = {
|
||||
singleLock: device.singleLock, // 是否单锁
|
||||
blockade: device.blockade, // 是否封锁
|
||||
routeLock: device.routeLock, // 是否进路锁闭
|
||||
overlapLock: device.overlapLock, // 是否进路延续保护锁闭
|
||||
normalPosition: device.normalPosition, // 是否定位
|
||||
reversePosition: device.reversePosition, // 是否反位
|
||||
fault: device.fault /** 非故障*/
|
||||
};
|
||||
|
||||
stateTransition[deviceType.Station] = {
|
||||
/** 是否故障*/
|
||||
fault: false, /** 非故障*/
|
||||
controlMode: 'Center' // Center 中控 Local 站控 Emergency 紧急站控 Interlock 联锁控
|
||||
}
|
||||
handleSignal(device) {
|
||||
this.statusObj = {
|
||||
fault: device.fault /** 非故障*/
|
||||
};
|
||||
|
||||
stateTransition[deviceType.Psd] = {
|
||||
/** 是否故障*/
|
||||
fault: false /** 非故障*/
|
||||
}
|
||||
handlePsd(device) {
|
||||
this.statusObj = {
|
||||
fault: device.fault /** 非故障*/
|
||||
};
|
||||
|
||||
stateTransition[deviceType.StationDelayUnlock] = {
|
||||
/** 是否故障*/
|
||||
fault: false /** 非故障*/
|
||||
}
|
||||
handleStationDelayUnlock(device) {
|
||||
this.statusObj = {
|
||||
fault: device.fault /** 非故障*/
|
||||
};
|
||||
|
||||
stateTransition[deviceType.StationStand] = {
|
||||
free: 1, // 站台空闲
|
||||
trainParking: 0, // 列车停站
|
||||
emergencyClosed: 0, // 站台紧急关闭
|
||||
stationHoldTrain: 0, // 站台是否扣车
|
||||
centerHoldTrain: 0, // 中心是否扣车 true 扣车 false 非扣车状态
|
||||
allSkip: 0, // 是否全部跳停
|
||||
assignSkip: 0, // 是否指定跳停
|
||||
runLevelTime: 0, // 区间运行时间 自动为 0
|
||||
parkingTime: 0, // 站台停车时间 自动为0
|
||||
/** 是否故障*/
|
||||
fault: false /** 非故障*/
|
||||
}
|
||||
handleTrain(device) {
|
||||
this.statusObj = {
|
||||
fault: device.fault /** 非故障*/
|
||||
};
|
||||
|
||||
stateTransition[deviceType.Train] = {
|
||||
/** 是否故障*/
|
||||
fault: false /** 非故障*/
|
||||
}
|
||||
handleStation(device) {
|
||||
this.statusObj = {
|
||||
controlMode: device.controlMode,
|
||||
fault: device.fault /** 非故障*/
|
||||
};
|
||||
|
||||
function transitionDeviceStatus(device) {
|
||||
const type = device._type;
|
||||
console.log(type);
|
||||
// stateTransition[type] = {}
|
||||
return {};
|
||||
}
|
||||
|
||||
export default {
|
||||
stateTransition,
|
||||
transitionDeviceStatus
|
||||
};
|
||||
getStatus() {
|
||||
return this.statusObj;
|
||||
}
|
||||
}
|
||||
|
||||
export default function transitionDeviceStatus(device) {
|
||||
const statusDevice = new Status(device);
|
||||
const status = statusDevice.getStatus();
|
||||
return deepAssign(device, status);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import * as zrUtil from 'zrender/src/core/util';
|
||||
import * as vector from 'zrender/src/core/vector';
|
||||
import Group from 'zrender/src/container/Group';
|
||||
import deviceType from './constant/deviceType';
|
||||
// import { transitionDeviceStatus } from './constant/stateTransition';
|
||||
import transitionDeviceStatus from './constant/stateTransition';
|
||||
import shapefactory from './shape/factory';
|
||||
import TransformHandle from './transformHandle';
|
||||
|
||||
@ -141,8 +141,7 @@ class Painter {
|
||||
} else {
|
||||
const instance = device.instance;
|
||||
if (instance) {
|
||||
// const device = transitionDeviceStatus(device); // 中间层转换状态数据
|
||||
instance.setState(device); // 改变试图状态
|
||||
instance.setState(transitionDeviceStatus(device)); // 改变试图状态
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -147,7 +147,6 @@ export default {
|
||||
},
|
||||
initMenu() {
|
||||
// 编辑模式菜单列表
|
||||
debugger;
|
||||
this.menu = MenuContextHandler.covert(this.menuNormal);
|
||||
// 故障模式菜单列表
|
||||
if (this.operatemode === OperateMode.FAULT) {
|
||||
|
Loading…
Reference in New Issue
Block a user