rt-sim-training-client/src/jmap/shape/factory.js

46 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-07-16 13:34:03 +08:00
import deviceType from '../constant/deviceType';
2019-07-18 10:05:16 +08:00
import Link from './Link/index.js';
import Section from './Section/index.js';
import Signal from './Signal/index.js';
import Station from './Station/index.js';
import StationControl from './StationControl/index.js';
import ImageControl from './ImageControl/index.js';
import LcControl from './LcControl/index.js';
import LimitControl from './LimitControl/index.js';
import Switch from './Switch/index.js';
import ZcControl from './ZcControl/index.js';
import StationCounter from './StationCounter/index.js';
import StationDelayUnlock from './StationDelayUnlock/index.js';
import StationStand from './StationStand/index.js';
import TrainWindow from './TrainWindow/index.js';
import Train from './Train/index.js';
2019-07-03 14:29:09 +08:00
2019-07-03 18:41:00 +08:00
/** 图库*/
2019-07-03 14:29:09 +08:00
const mapShape = {};
mapShape[deviceType.Link] = Link;
mapShape[deviceType.Section] = Section;
2019-07-15 10:06:07 +08:00
mapShape[deviceType.Signal] = Signal;
2019-07-15 15:25:49 +08:00
mapShape[deviceType.Station] = Station;
mapShape[deviceType.StationControl] = StationControl;
mapShape[deviceType.ImageControl] = ImageControl;
mapShape[deviceType.LcControl] = LcControl;
mapShape[deviceType.LimitControl] = LimitControl;
2019-07-15 14:01:57 +08:00
mapShape[deviceType.Switch] = Switch;
2019-07-15 15:47:03 +08:00
mapShape[deviceType.ZcControl] = ZcControl;
2019-07-15 15:33:18 +08:00
mapShape[deviceType.StationCounter] = StationCounter;
mapShape[deviceType.StationDelayUnlock] = StationDelayUnlock;
2019-07-15 18:06:10 +08:00
mapShape[deviceType.StationStand] = StationStand;
mapShape[deviceType.TrainWindow] = TrainWindow;
mapShape[deviceType.Train] = Train;
2019-07-03 14:29:09 +08:00
2019-07-15 14:01:57 +08:00
function shapefactory(type, device, jmap) {
const style = jmap.getStyleDict();
2019-07-04 10:59:40 +08:00
const shape = mapShape[type];
if (shape instanceof Function) {
2019-07-16 13:34:03 +08:00
// eslint-disable-next-line
return new shape(device, style, jmap);
2019-07-04 10:59:40 +08:00
}
2019-07-03 14:29:09 +08:00
}
2019-07-11 17:58:58 +08:00
export default shapefactory;