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