测试道岔
This commit is contained in:
parent
5eecd80622
commit
686ff255e5
@ -1,6 +1,6 @@
|
||||
import { JlGraphic, VectorText } from 'jl-graphic';
|
||||
import { IPointData, Graphics } from 'pixi.js';
|
||||
import { DevicePort } from 'common/common';
|
||||
import { DevicePort, IRelatedRef } from 'common/common';
|
||||
import { ITurnoutData, TurnoutConstsConfig } from './TurnoutConfig';
|
||||
import { JlSection } from 'src/packages/Section/common/JlSection';
|
||||
export declare function getForkPoint(r: number, p: IPointData): IPointData;
|
||||
@ -27,6 +27,9 @@ export declare abstract class JlTurnout extends JlGraphic {
|
||||
sections: [TurnoutSection, TurnoutSection, TurnoutSection];
|
||||
label: VectorText;
|
||||
};
|
||||
handleData?: {
|
||||
handleRefDeviceData: (data: IRelatedRef) => IRelatedRef;
|
||||
};
|
||||
constructor(turnoutConsts: TurnoutConstsConfig);
|
||||
get datas(): ITurnoutData;
|
||||
get code(): string;
|
||||
|
@ -69,6 +69,7 @@ class ForkGraphic extends Graphics {
|
||||
class JlTurnout extends JlGraphic {
|
||||
static Type = 'Turnout';
|
||||
graphics;
|
||||
handleData;
|
||||
constructor(turnoutConsts) {
|
||||
super(JlTurnout.Type);
|
||||
this.name = 'turnout';
|
||||
@ -188,7 +189,8 @@ class JlTurnout extends JlGraphic {
|
||||
relation.getOtherGraphic(this) instanceof JlTurnout));
|
||||
const paDevice = paRelation?.getOtherGraphic(this);
|
||||
if (paDevice) {
|
||||
this.datas.paRef = IRelatedRef.create(paDevice.type, paDevice.id, paRelation.getOtherRelationParam(this).getParam());
|
||||
const refData = IRelatedRef.create(paDevice.type, paDevice.id, paRelation.getOtherRelationParam(this).getParam());
|
||||
this.datas.paRef = this.handleData?.handleRefDeviceData(refData);
|
||||
}
|
||||
else {
|
||||
this.datas.paRef = undefined;
|
||||
@ -200,7 +202,8 @@ class JlTurnout extends JlGraphic {
|
||||
relation.getOtherGraphic(this) instanceof JlTurnout));
|
||||
const pbDevice = pbRelation?.getOtherGraphic(this);
|
||||
if (pbDevice) {
|
||||
this.datas.pbRef = IRelatedRef.create(pbDevice.type, pbDevice.id, pbRelation.getOtherRelationParam(this).getParam());
|
||||
const refData = IRelatedRef.create(pbDevice.type, pbDevice.id, pbRelation.getOtherRelationParam(this).getParam());
|
||||
this.datas.pbRef = this.handleData?.handleRefDeviceData(refData);
|
||||
}
|
||||
else {
|
||||
this.datas.pbRef = undefined;
|
||||
@ -213,7 +216,8 @@ class JlTurnout extends JlGraphic {
|
||||
SectionType.TurnoutPhysical));
|
||||
const pcDevice = pcRelation?.getOtherGraphic(this);
|
||||
if (pcDevice) {
|
||||
this.datas.pcRef = IRelatedRef.create(pcDevice.type, pcDevice.id, pcRelation.getOtherRelationParam(this).getParam());
|
||||
const refData = IRelatedRef.create(pcDevice.type, pcDevice.id, pcRelation.getOtherRelationParam(this).getParam());
|
||||
this.datas.pcRef = this.handleData?.handleRefDeviceData(refData);
|
||||
}
|
||||
else {
|
||||
this.datas.pcRef = undefined;
|
||||
@ -221,13 +225,13 @@ class JlTurnout extends JlGraphic {
|
||||
}
|
||||
loadCommonRelations() {
|
||||
if (this.datas.paRef?.id) {
|
||||
this.relationManage.addRelation(new GraphicRelationParam(this, DevicePort.A), new GraphicRelationParam(this.queryStore.queryById(this.datas.paRef.id), DevicePort[this.datas.paRef.devicePort]));
|
||||
this.relationManage.addRelation(new GraphicRelationParam(this, DevicePort.A), new GraphicRelationParam(this.queryStore.queryById(this.datas.paRef.id), this.datas.paRef.devicePort));
|
||||
}
|
||||
if (this.datas.pbRef?.id) {
|
||||
this.relationManage.addRelation(new GraphicRelationParam(this, DevicePort.B), new GraphicRelationParam(this.queryStore.queryById(this.datas.pbRef.id), DevicePort[this.datas.pbRef.devicePort]));
|
||||
this.relationManage.addRelation(new GraphicRelationParam(this, DevicePort.B), new GraphicRelationParam(this.queryStore.queryById(this.datas.pbRef.id), this.datas.pbRef.devicePort));
|
||||
}
|
||||
if (this.datas.pcRef?.id) {
|
||||
this.relationManage.addRelation(new GraphicRelationParam(this, DevicePort.C), new GraphicRelationParam(this.queryStore.queryById(this.datas.pcRef.id), DevicePort[this.datas.pcRef.devicePort]));
|
||||
this.relationManage.addRelation(new GraphicRelationParam(this, DevicePort.C), new GraphicRelationParam(this.queryStore.queryById(this.datas.pcRef.id), this.datas.pcRef.devicePort));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
import { GraphicState, JlGraphicTemplate } from 'jl-graphic';
|
||||
import { JlTurnout } from './JlTurnout';
|
||||
import { ITurnoutData } from './TurnoutConfig';
|
||||
import { StyleType } from 'common/common';
|
||||
import { IRelatedRef, StyleType } from 'common/common';
|
||||
export declare class TurnoutTemplate<S extends GraphicState> extends JlGraphicTemplate<JlTurnout> {
|
||||
styleType: StyleType;
|
||||
constructor(dataTemplate: ITurnoutData, stateTemplate: S, styleType: StyleType);
|
||||
handleData: {
|
||||
handleRefDeviceData: (data: IRelatedRef) => IRelatedRef;
|
||||
};
|
||||
constructor(dataTemplate: ITurnoutData, stateTemplate: S, styleType: StyleType, handleData: {
|
||||
handleRefDeviceData: (data: IRelatedRef) => IRelatedRef;
|
||||
});
|
||||
new(): JlTurnout;
|
||||
}
|
||||
|
@ -6,12 +6,14 @@ import { THTurnout } from '../THTurnout.js';
|
||||
|
||||
class TurnoutTemplate extends JlGraphicTemplate {
|
||||
styleType;
|
||||
constructor(dataTemplate, stateTemplate, styleType) {
|
||||
handleData;
|
||||
constructor(dataTemplate, stateTemplate, styleType, handleData) {
|
||||
super(JlTurnout.Type, {
|
||||
dataTemplate,
|
||||
stateTemplate,
|
||||
});
|
||||
this.styleType = styleType;
|
||||
this.handleData = handleData;
|
||||
}
|
||||
new() {
|
||||
let turnout;
|
||||
@ -23,6 +25,7 @@ class TurnoutTemplate extends JlGraphicTemplate {
|
||||
turnout = new THTurnout();
|
||||
break;
|
||||
}
|
||||
turnout.handleData = this.handleData;
|
||||
turnout.loadData(this.datas);
|
||||
turnout.loadState(this.states);
|
||||
return turnout;
|
||||
|
@ -89,6 +89,7 @@ export abstract class JlTurnout extends JlGraphic {
|
||||
sections: [TurnoutSection, TurnoutSection, TurnoutSection];
|
||||
label: VectorText;
|
||||
};
|
||||
handleData?: { handleRefDeviceData: (data: IRelatedRef) => IRelatedRef };
|
||||
|
||||
constructor(turnoutConsts: TurnoutConstsConfig) {
|
||||
super(JlTurnout.Type);
|
||||
@ -258,11 +259,12 @@ export abstract class JlTurnout extends JlGraphic {
|
||||
);
|
||||
const paDevice = paRelation?.getOtherGraphic<JlSection | JlTurnout>(this);
|
||||
if (paDevice) {
|
||||
this.datas.paRef = IRelatedRef.create(
|
||||
const refData = IRelatedRef.create(
|
||||
paDevice.type,
|
||||
paDevice.id,
|
||||
paRelation!.getOtherRelationParam(this).getParam(),
|
||||
);
|
||||
this.datas.paRef = this.handleData?.handleRefDeviceData(refData);
|
||||
} else {
|
||||
this.datas.paRef = undefined;
|
||||
}
|
||||
@ -276,11 +278,12 @@ export abstract class JlTurnout extends JlGraphic {
|
||||
);
|
||||
const pbDevice = pbRelation?.getOtherGraphic<JlSection | JlTurnout>(this);
|
||||
if (pbDevice) {
|
||||
this.datas.pbRef = IRelatedRef.create(
|
||||
const refData = IRelatedRef.create(
|
||||
pbDevice.type,
|
||||
pbDevice.id,
|
||||
pbRelation!.getOtherRelationParam(this).getParam(),
|
||||
);
|
||||
this.datas.pbRef = this.handleData?.handleRefDeviceData(refData);
|
||||
} else {
|
||||
this.datas.pbRef = undefined;
|
||||
}
|
||||
@ -298,11 +301,12 @@ export abstract class JlTurnout extends JlGraphic {
|
||||
);
|
||||
const pcDevice = pcRelation?.getOtherGraphic<JlSection | JlTurnout>(this);
|
||||
if (pcDevice) {
|
||||
this.datas.pcRef = IRelatedRef.create(
|
||||
const refData = IRelatedRef.create(
|
||||
pcDevice.type,
|
||||
pcDevice.id,
|
||||
pcRelation!.getOtherRelationParam(this).getParam(),
|
||||
);
|
||||
this.datas.pcRef = this.handleData?.handleRefDeviceData(refData);
|
||||
} else {
|
||||
this.datas.pcRef = undefined;
|
||||
}
|
||||
@ -313,7 +317,7 @@ export abstract class JlTurnout extends JlGraphic {
|
||||
new GraphicRelationParam(this, DevicePort.A),
|
||||
new GraphicRelationParam(
|
||||
this.queryStore.queryById(this.datas.paRef.id),
|
||||
DevicePort[this.datas.paRef.devicePort],
|
||||
this.datas.paRef.devicePort,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -322,7 +326,7 @@ export abstract class JlTurnout extends JlGraphic {
|
||||
new GraphicRelationParam(this, DevicePort.B),
|
||||
new GraphicRelationParam(
|
||||
this.queryStore.queryById(this.datas.pbRef.id),
|
||||
DevicePort[this.datas.pbRef.devicePort],
|
||||
this.datas.pbRef.devicePort,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -331,7 +335,7 @@ export abstract class JlTurnout extends JlGraphic {
|
||||
new GraphicRelationParam(this, DevicePort.C),
|
||||
new GraphicRelationParam(
|
||||
this.queryStore.queryById(this.datas.pcRef.id),
|
||||
DevicePort[this.datas.pcRef.devicePort],
|
||||
this.datas.pcRef.devicePort,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { GraphicState, JlGraphicTemplate } from 'jl-graphic';
|
||||
import { JlTurnout } from './JlTurnout';
|
||||
import { ITurnoutData } from './TurnoutConfig';
|
||||
import { StyleType } from 'common/common';
|
||||
import { IRelatedRef, StyleType } from 'common/common';
|
||||
import { GPTurnout } from '../GPTurnout';
|
||||
import { THTurnout } from '../THTurnout';
|
||||
|
||||
@ -9,16 +9,19 @@ export class TurnoutTemplate<
|
||||
S extends GraphicState,
|
||||
> extends JlGraphicTemplate<JlTurnout> {
|
||||
styleType: StyleType;
|
||||
handleData: { handleRefDeviceData: (data: IRelatedRef) => IRelatedRef };
|
||||
constructor(
|
||||
dataTemplate: ITurnoutData,
|
||||
stateTemplate: S,
|
||||
styleType: StyleType,
|
||||
handleData: { handleRefDeviceData: (data: IRelatedRef) => IRelatedRef },
|
||||
) {
|
||||
super(JlTurnout.Type, {
|
||||
dataTemplate,
|
||||
stateTemplate,
|
||||
});
|
||||
this.styleType = styleType;
|
||||
this.handleData = handleData;
|
||||
}
|
||||
|
||||
new() {
|
||||
@ -31,6 +34,7 @@ export class TurnoutTemplate<
|
||||
turnout = new THTurnout();
|
||||
break;
|
||||
}
|
||||
turnout.handleData = this.handleData;
|
||||
turnout.loadData(this.datas);
|
||||
turnout.loadState(this.states);
|
||||
return turnout;
|
||||
|
Loading…
Reference in New Issue
Block a user