import { JlGraphic, GraphicRelationParam, JlGraphicTemplate } from 'jl-graphic'; import { DevicePort } from '../../common/common.js'; import { Container, Graphics, Color } from 'pixi.js'; var TypeDetectionPoint; (function (TypeDetectionPoint) { TypeDetectionPoint[TypeDetectionPoint["AxleCounting"] = 0] = "AxleCounting"; TypeDetectionPoint[TypeDetectionPoint["SectionBoundary"] = 1] = "SectionBoundary"; })(TypeDetectionPoint || (TypeDetectionPoint = {})); const AxleCountingConsts = { radius: 6, borderWidth: 1, circleColorBlue: '0x08F80D', circleColorRed: '0xff0000', }; class TwoCircleGraphic extends Container { circleA = new Graphics(); circleB = new Graphics(); line = new Graphics(); constructor() { super(); this.addChild(this.circleA); this.addChild(this.circleB); this.addChild(this.line); } draw(data) { this.drawCircle(this.circleA, data); this.drawCircle(this.circleB, data); this.circleA.position.set(-12, 0); this.circleB.position.set(12, 0); const color = data.type == 1 ? AxleCountingConsts.circleColorRed : AxleCountingConsts.circleColorBlue; this.line .clear() .lineStyle(1, new Color(color)) .moveTo(-24, 0) .lineTo(24, 0); } drawCircle(circle, data) { const color = data.type == 1 ? AxleCountingConsts.circleColorRed : AxleCountingConsts.circleColorBlue; circle .clear() .lineStyle(AxleCountingConsts.borderWidth, new Color(color)) .beginFill(color, 1) .drawCircle(0, 0, AxleCountingConsts.radius).endFill; } clear() { this.circleA.clear(); this.circleB.clear(); } } class AxleCounting extends JlGraphic { static Type = 'AxleCounting'; twoCircle = new TwoCircleGraphic(); direction; constructor(direction) { super(AxleCounting.Type); this.addChild(this.twoCircle); this.direction = direction; } get datas() { return this.getDatas(); } doRepaint() { this.twoCircle.draw(this.datas); } buildRelation() { this.loadRelations(); } loadRelations() { if (this.datas.axleCountingRef.length) { this.datas.axleCountingRef.forEach((device) => { this.relationManage.addRelation(new GraphicRelationParam(this, 'A'), new GraphicRelationParam(this.queryStore.queryById(device.id), DevicePort[device.devicePort])); }); } } } class AxleCountingTemplate extends JlGraphicTemplate { constructor(dataTemplate) { super(AxleCounting.Type, { dataTemplate, }); } new() { const axleCounting = new AxleCounting(1); axleCounting.loadData(this.datas); return axleCounting; } } export { AxleCounting, AxleCountingConsts, AxleCountingTemplate };