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