rt-sim-training-client/src/jmap/shape/factory.js
2019-07-19 13:54:23 +08:00

46 lines
1.7 KiB
JavaScript

import deviceType from '../constant/deviceType';
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';
/** 图库*/
const mapShape = {};
mapShape[deviceType.Link] = Link;
mapShape[deviceType.Section] = Section;
mapShape[deviceType.Signal] = Signal;
mapShape[deviceType.Station] = Station;
mapShape[deviceType.StationControl] = StationControl;
mapShape[deviceType.ImageControl] = ImageControl;
mapShape[deviceType.LcControl] = LcControl;
mapShape[deviceType.LimitControl] = LimitControl;
mapShape[deviceType.Switch] = Switch;
mapShape[deviceType.ZcControl] = ZcControl;
mapShape[deviceType.StationCounter] = StationCounter;
mapShape[deviceType.StationDelayUnlock] = StationDelayUnlock;
mapShape[deviceType.StationStand] = StationStand;
mapShape[deviceType.TrainWindow] = TrainWindow;
mapShape[deviceType.Train] = Train;
function shapefactory(type, device, jmap) {
const style = jmap.getStyleDict();
const shape = mapShape[type];
if (shape instanceof Function) {
// eslint-disable-next-line
return new shape(device, style);
}
}
export default shapefactory;