96 lines
3.3 KiB
JavaScript
96 lines
3.3 KiB
JavaScript
import { deepAssign } from '@/utils/index';
|
||
|
||
// 所有默认状态在这里都要有 用来转换后台发送的数据状态
|
||
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 /** 非故障*/
|
||
};
|
||
}
|
||
handleSection(device) {
|
||
this.statusObj = {
|
||
blockade: device.blockade, // 是否封锁
|
||
routeLock: device.routeLock, // 是否进路锁闭
|
||
overlapLock: device.overlapLock, // 进路延续保护锁闭
|
||
ctOccupied: device.ctOccupied, // 通信车占用
|
||
nctOccupied: device.nctOccupied, // 非通信车占用
|
||
fault: device.fault /** 非故障*/
|
||
};
|
||
}
|
||
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 /** 非故障*/
|
||
};
|
||
}
|
||
handleSignal(device) {
|
||
this.statusObj = {
|
||
fault: device.fault, /** 非故障*/
|
||
atsControl: device.atsControl, /** 0是人工控制,1是自动控制 */
|
||
blockade: device.blockade,
|
||
logicLight: device.logicLight,
|
||
greenOpen: device.greenOpen,
|
||
redOpen: device.redOpen,
|
||
yellowOpen: device.yellowOpen
|
||
};
|
||
}
|
||
handlePsd(device) {
|
||
this.statusObj = {
|
||
fault: device.fault /** 非故障*/
|
||
};
|
||
}
|
||
handleStationDelayUnlock(device) {
|
||
this.statusObj = {
|
||
fault: device.fault /** 非故障*/
|
||
};
|
||
}
|
||
handleTrain(device) {
|
||
this.statusObj = {
|
||
fault: device.fault /** 非故障*/
|
||
};
|
||
}
|
||
handleStation(device) {
|
||
this.statusObj = {
|
||
controlMode: device.controlMode,
|
||
fault: device.fault /** 非故障*/
|
||
};
|
||
}
|
||
handleZcControl(device) {
|
||
this.statusObj = {
|
||
};
|
||
}
|
||
getStatus() {
|
||
return this.statusObj;
|
||
}
|
||
}
|
||
|
||
export default function transitionDeviceStatus(device) {
|
||
const statusDevice = new Status(device);
|
||
const status = statusDevice.getStatus();
|
||
return deepAssign(device, status);
|
||
}
|