import { Graphics } from 'pixi.js'; import { JlGraphic, GraphicRelationParam, JlGraphicTemplate } from 'jl-graphic'; import { LampMainBody } from './LampMainBody.js'; import { SignalCode } from '../common/SignalCode.js'; /** 信号机类型 */ var Model; (function (Model) { Model[Model["HL"] = 0] = "HL"; Model[Model["HLU_FU"] = 1] = "HLU_FU"; Model[Model["HLU_DU_YY"] = 2] = "HLU_DU_YY"; Model[Model["HLU_YY"] = 3] = "HLU_YY"; Model[Model["HLU_FL_DU_YY"] = 4] = "HLU_FL_DU_YY"; Model[Model["HLU_DU"] = 5] = "HLU_DU"; Model[Model["AB"] = 6] = "AB"; Model[Model["HBU_DU"] = 7] = "HBU_DU"; })(Model || (Model = {})); var Direction; (function (Direction) { Direction[Direction["LEFT"] = 0] = "LEFT"; Direction[Direction["RIGHT"] = 1] = "RIGHT"; })(Direction || (Direction = {})); var DeviceType; (function (DeviceType) { DeviceType[DeviceType["Section"] = 0] = "Section"; DeviceType[DeviceType["Turnout"] = 1] = "Turnout"; DeviceType[DeviceType["TrainWindow"] = 2] = "TrainWindow"; DeviceType[DeviceType["AxleCounting"] = 3] = "AxleCounting"; DeviceType[DeviceType["SectionLink"] = 4] = "SectionLink"; DeviceType[DeviceType["signal"] = 5] = "signal"; DeviceType[DeviceType["station"] = 6] = "station"; DeviceType[DeviceType["ScreenDoor"] = 7] = "ScreenDoor"; DeviceType[DeviceType["SignalFaultAlarm"] = 8] = "SignalFaultAlarm"; DeviceType[DeviceType["Breakers"] = 9] = "Breakers"; DeviceType[DeviceType["PowerScreen"] = 10] = "PowerScreen"; })(DeviceType || (DeviceType = {})); var Aspect; (function (Aspect) { Aspect[Aspect["Non"] = 0] = "Non"; Aspect[Aspect["OFF"] = 1] = "OFF"; Aspect[Aspect["L"] = 2] = "L"; Aspect[Aspect["H"] = 3] = "H"; Aspect[Aspect["U"] = 4] = "U"; Aspect[Aspect["HU"] = 5] = "HU"; Aspect[Aspect["B"] = 6] = "B"; Aspect[Aspect["A"] = 7] = "A"; })(Aspect || (Aspect = {})); var DevicePort; (function (DevicePort) { DevicePort[DevicePort["A"] = 0] = "A"; DevicePort[DevicePort["B"] = 1] = "B"; DevicePort[DevicePort["C"] = 2] = "C"; })(DevicePort || (DevicePort = {})); var SignalColorEnum; (function (SignalColorEnum) { SignalColorEnum["humanControlColor"] = "0xffff00"; SignalColorEnum["fleetModeColor"] = "0x00ff00"; SignalColorEnum["blockedColor"] = "0XFF0000"; SignalColorEnum["defaultCodeColor"] = "0XFFFFFF"; SignalColorEnum["lampPostColor"] = "0xFFFFFF"; SignalColorEnum["redLamp"] = "0XFF0000"; SignalColorEnum["greenLamp"] = "0X00FF00"; SignalColorEnum["yellowLamp"] = "0XFFFF00"; SignalColorEnum["whiteLamp"] = "0XFFFFFF"; SignalColorEnum["blueLamp"] = "0X0033FF"; SignalColorEnum["closeLamp"] = "0X000000"; SignalColorEnum["logicModeColor"] = "0x000000"; SignalColorEnum["lampLineColor"] = "0x3149c3"; })(SignalColorEnum || (SignalColorEnum = {})); const signalConsts = { fleetModeLength: 24, fleetModeRadius: 8, fleetModeLineWidth: 6, humanControlRadius: 8, codeOffset: 20, codeFontSize: 11, blockedLineWidth: 1, verticalLampPostLength: 16, levelLampPostLength: 4, postLineWidth: 3, lampRadius: 8, logicModeLineWidth: 2, logicModeDistance: 5, lampLineWidth: 1, }; class Signal extends JlGraphic { static Type = 'signal'; signalCode = new SignalCode(); humanControl = new Graphics(); fleetMode = new Graphics(); lampMainBody = new LampMainBody(); blockedMode = new Graphics(); constructor() { super(Signal.Type); // this.addChild(this.humanControl); // this.addChild(this.fleetMode); this.addChild(this.lampMainBody); this.addChild(this.signalCode); } get datas() { return this.getDatas(); } get mirror() { return this.datas.mirror; } set mirror(v) { const old = this.datas.clone(); old.mirror = v; this.updateData(old); } get states() { return this.getStates(); } paint() { const mirror = this.datas.mirror; this.lampMainBody.paint(this.datas.mt, mirror); this.signalCode.paint(this.datas); const codeTransform = this.datas?.childTransforms?.find((item) => item.name === 'signalCode'); if (codeTransform) { const position = codeTransform?.transform.position; const rotation = codeTransform?.transform?.rotation; this.signalCode.position.set(position?.x, position?.y); this.signalCode.rotation = rotation || 0; } else { this.signalCode.position.set(0, signalConsts.codeOffset); } } doRepaint() { this.paint(); } chagneState() { switch (this.states.aspect) { case Aspect.OFF: this.setStateOff(); case Aspect.H: this.setStateH(); break; case Aspect.L: this.setStateL(); break; case Aspect.U: this.setStateU(); break; case Aspect.HU: this.setStateHu(); break; case Aspect.A: this.setStateA(); break; case Aspect.B: this.setStateB(); break; } } /** 设置状态自动进路 */ // setStateFleetMode(): void { // const mirror = this.datas.mirror; // this.fleetMode.beginFill(SignalColorEnum.fleetModeColor, 1); // let lmp = new Point( // this.lampMainBody.width + signalConsts.fleetModeLength, // 0 // ); // if (mirror) { // lmp = calculateMirrorPoint(new Point(0, 0), lmp); // } // drawArrow( // this.fleetMode, // lmp.x, // 0, // signalConsts.fleetModeLength, // signalConsts.fleetModeRadius, // signalConsts.fleetModeLineWidth, // mirror // ); // this.fleetMode.endFill(); // } /** 设置状态人工控 */ // setStateHumanControl(): void { // const mirror = this.datas.mirror; // this.humanControl.beginFill(SignalColorEnum.humanControlColor, 1); // if (this.humanControl.drawRegularPolygon) { // let hmp = new Point(-signalConsts.humanControlRadius, 0); // if (mirror) { // hmp = calculateMirrorPoint(new Point(0, 0), hmp); // } // this.humanControl.drawRegularPolygon( // hmp.x, // hmp.y, // signalConsts.humanControlRadius, // 3, // (Math.PI / 2) * (mirror ? -1 : 1) // ); // } // this.humanControl.endFill(); // } /** 设置状态封锁 */ // setStateBlocked() { // this.signalCode.createBlockedMode(); // } /** 设置状态红灯 */ setStateH() { this.lampMainBody.setStateH(); } /** 设置状态绿灯 */ setStateL() { this.lampMainBody.setStateL(); } /** 设置状态黄灯 */ setStateU() { this.lampMainBody.setStateU(); } /** 设置状态红黄灯 */ setStateHu() { this.lampMainBody.setStateHu(); } /** 设置状态白灯 */ setStateA() { this.lampMainBody.setStateA(); } /** 设置状态蓝灯 */ setStateB() { this.lampMainBody.setStateB(); } /** 设置状态灯位关闭 */ setStateOff() { this.lampMainBody.setStateOff(); } buildRelation() { // .... } loadRelations() { if (this.datas.refDev) { this.relationManage.addRelation(new GraphicRelationParam(this, ''), new GraphicRelationParam(this.queryStore.queryById(this.datas.refDev.id), this.datas.refDev.devicePort)); } } } class SignalTemplate extends JlGraphicTemplate { constructor(dataTemplate, stateTemplate) { super(Signal.Type, { dataTemplate, stateTemplate }); } new() { const g = new Signal(); g.loadData(this.datas); g.loadState(this.states); return g; } } export { Aspect, DevicePort, DeviceType, Direction, Model, Signal, SignalColorEnum, SignalTemplate, signalConsts };