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

39 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-07-03 14:29:09 +08:00
import deviceType from '../config/deviceType';
import Link from './Link';
2019-07-15 15:58:09 +08:00
import Section from './Section';
2019-07-15 10:06:07 +08:00
import Signal from './Signal';
2019-07-15 15:58:09 +08:00
import Station from './Station';
2019-07-15 15:25:49 +08:00
import StationControl from './StationControl';
import ImageControl from './ImageControl';
2019-07-15 15:58:09 +08:00
import LcControl from './LcControl';
import LimitControl from './LimitControl';
2019-07-15 14:01:57 +08:00
import Switch from './Switch';
2019-07-15 15:47:03 +08:00
import ZcControl from './ZcControl';
2019-07-15 15:33:18 +08:00
import StationCounter from './StationCounter';
import StationDelayUnlock from './StationDelayUnlock';
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-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-15 14:01:57 +08:00
return new shape(device, style[type], 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;