Merge branch 'master' of https://git.code.tencent.com/beijing-rtss-test/bj-rtss-client
This commit is contained in:
commit
37ba668e94
@ -49,17 +49,43 @@
|
||||
@update:model-value="onUpdate"
|
||||
label="应答器类型"
|
||||
></q-select>
|
||||
<q-field class="q-mt-lg" outlined label="关联区段" readonly stack-label>
|
||||
<template #control>
|
||||
<q-chip
|
||||
color="primary"
|
||||
text-color="white"
|
||||
v-for="code in sectionRelations"
|
||||
:key="code"
|
||||
square
|
||||
>{{ code }}</q-chip
|
||||
>
|
||||
</template>
|
||||
</q-field>
|
||||
<q-field class="q-mt-lg" outlined label="关联道岔" readonly stack-label>
|
||||
<template #control>
|
||||
<q-chip
|
||||
color="primary"
|
||||
text-color="white"
|
||||
v-for="code in turnoutRelations"
|
||||
:key="code"
|
||||
square
|
||||
>{{ code }}</q-chip
|
||||
>
|
||||
</template>
|
||||
</q-field>
|
||||
</q-form>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { TransponderData } from 'src/drawApp/graphics/TransponderInteraction';
|
||||
import { Section } from 'src/graphics/section/Section';
|
||||
import {
|
||||
Transponder,
|
||||
transponderTypeEnum,
|
||||
} from 'src/graphics/transponder/Transponder';
|
||||
import { Turnout } from 'src/graphics/turnout/Turnout';
|
||||
import { useDrawStore } from 'src/stores/draw-store';
|
||||
import { onMounted, reactive, watch } from 'vue';
|
||||
import { computed, onMounted, reactive, watch } from 'vue';
|
||||
|
||||
const drawStore = useDrawStore();
|
||||
const transponderModel = reactive(new TransponderData());
|
||||
@ -119,4 +145,33 @@ function onUpdate() {
|
||||
.updateGraphicAndRecord(Transponder, transponderModel);
|
||||
}
|
||||
}
|
||||
|
||||
const sectionRelations = computed(() => {
|
||||
const transponder = drawStore.selectedGraphic as Transponder;
|
||||
|
||||
const relations =
|
||||
transponder.relationManage.getRelationsOfGraphicAndOtherType(
|
||||
transponder,
|
||||
Section.Type
|
||||
);
|
||||
return relations.map(
|
||||
(relation) =>
|
||||
`${relation.getOtherGraphic<Transponder>(transponder).datas.code}`
|
||||
);
|
||||
});
|
||||
const turnoutRelations = computed(() => {
|
||||
const transponder = drawStore.selectedGraphic as Transponder;
|
||||
|
||||
const relations =
|
||||
transponder.relationManage.getRelationsOfGraphicAndOtherType(
|
||||
transponder,
|
||||
Turnout.Type
|
||||
);
|
||||
return relations.map(
|
||||
(relation) =>
|
||||
`${relation.getOtherGraphic<Transponder>(transponder).datas.code}(${
|
||||
relation.getOtherRelationParam(transponder).param
|
||||
})`
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
@ -50,6 +50,12 @@ export class TransponderData
|
||||
set kilometerSystem(v: KilometerSystem) {
|
||||
this.data.kilometerSystem = new graphicData.KilometerSystem(v);
|
||||
}
|
||||
get TransponderRef(): graphicData.RelatedRef {
|
||||
return this.data.TransponderRef;
|
||||
}
|
||||
set TransponderRef(v: graphicData.RelatedRef) {
|
||||
this.data.TransponderRef = v;
|
||||
}
|
||||
clone(): TransponderData {
|
||||
return new TransponderData(this.data.cloneMessage());
|
||||
}
|
||||
|
@ -1,11 +1,20 @@
|
||||
import { Container, Graphics } from 'pixi.js';
|
||||
import { Container, Graphics, Point } from 'pixi.js';
|
||||
import {
|
||||
GraphicData,
|
||||
GraphicRelationParam,
|
||||
JlGraphic,
|
||||
JlGraphicTemplate,
|
||||
VectorText,
|
||||
linePoint,
|
||||
} from 'src/jl-graphic';
|
||||
import { KilometerSystem } from '../signal/Signal';
|
||||
import {
|
||||
IRelatedRefData,
|
||||
createRelatedRefProto,
|
||||
protoPort2Data,
|
||||
} from '../CommonGraphics';
|
||||
import { Section, SectionConsts, SectionPort } from '../section/Section';
|
||||
import { Turnout, TurnoutConsts, TurnoutPort } from '../turnout/Turnout';
|
||||
|
||||
export interface ITransponderData extends GraphicData {
|
||||
get code(): string; // 编号
|
||||
@ -16,6 +25,8 @@ export interface ITransponderData extends GraphicData {
|
||||
set index(v: number);
|
||||
get kilometerSystem(): KilometerSystem;
|
||||
set kilometerSystem(v: KilometerSystem);
|
||||
get TransponderRef(): IRelatedRefData;
|
||||
set TransponderRef(v: IRelatedRefData);
|
||||
clone(): ITransponderData;
|
||||
copyFrom(data: ITransponderData): void;
|
||||
eq(other: ITransponderData): boolean;
|
||||
@ -156,6 +167,102 @@ export class Transponder extends JlGraphic {
|
||||
);
|
||||
}
|
||||
}
|
||||
buildRelation() {
|
||||
this.relationManage.deleteRelationOfGraphic(this);
|
||||
const { x, y } = this.position;
|
||||
const sections = this.queryStore.queryByType<Section>(Section.Type);
|
||||
const findSection = sections.find((section) => {
|
||||
let s = false;
|
||||
for (let i = 1; i < section.datas.points.length; i++) {
|
||||
const p1 = section.datas.points[i - 1];
|
||||
const p2 = section.datas.points[i];
|
||||
if (
|
||||
linePoint(
|
||||
section.localToCanvasPoint(p1),
|
||||
section.localToCanvasPoint(p2),
|
||||
{ x, y },
|
||||
SectionConsts.lineWidth
|
||||
)
|
||||
) {
|
||||
s = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
});
|
||||
if (findSection) {
|
||||
this.relationManage.addRelation(
|
||||
new GraphicRelationParam(this),
|
||||
new GraphicRelationParam(findSection, SectionPort.A)
|
||||
);
|
||||
return;
|
||||
}
|
||||
let tPort: TurnoutPort | null = null;
|
||||
const portList = [TurnoutPort.A, TurnoutPort.B, TurnoutPort.C];
|
||||
const turnouts = this.queryStore.queryByType<Turnout>(Turnout.Type);
|
||||
const findTurnout = turnouts.find((turnout) => {
|
||||
let s = false;
|
||||
const aPs = turnout.getPortPoints();
|
||||
aPs.some((item, index) => {
|
||||
const Ps = [new Point(0, 0), ...item];
|
||||
for (let i = 1; i < Ps.length; i++) {
|
||||
const p1 = Ps[i - 1];
|
||||
const p2 = Ps[i];
|
||||
if (
|
||||
linePoint(
|
||||
turnout.localToCanvasPoint(p1),
|
||||
turnout.localToCanvasPoint(p2),
|
||||
{ x, y },
|
||||
TurnoutConsts.lineWidth
|
||||
)
|
||||
) {
|
||||
s = true;
|
||||
tPort = portList[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
});
|
||||
return s;
|
||||
});
|
||||
if (findTurnout) {
|
||||
this.relationManage.addRelation(
|
||||
new GraphicRelationParam(this),
|
||||
new GraphicRelationParam(findTurnout, tPort)
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
saveRelations() {
|
||||
const relationM = this.relationManage
|
||||
.getRelationsOfGraphic(this)
|
||||
.find(
|
||||
(relation) =>
|
||||
relation.getOtherGraphic(this) instanceof Section ||
|
||||
relation.getOtherGraphic(this) instanceof Turnout
|
||||
);
|
||||
const device = relationM?.getOtherGraphic<Section | Turnout>(this);
|
||||
if (device) {
|
||||
this.datas.TransponderRef = createRelatedRefProto(
|
||||
device.type,
|
||||
device.id,
|
||||
relationM?.getOtherRelationParam(this).param
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
loadRelations() {
|
||||
if (this.datas?.TransponderRef?.id) {
|
||||
this.relationManage.addRelation(
|
||||
new GraphicRelationParam(this),
|
||||
new GraphicRelationParam(
|
||||
this.queryStore.queryById(this.datas.TransponderRef.id),
|
||||
protoPort2Data(this.datas.TransponderRef.devicePort)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class TransponderTemplate extends JlGraphicTemplate<Transponder> {
|
||||
|
@ -2950,6 +2950,7 @@ export namespace graphicData {
|
||||
transponderType?: number;
|
||||
index?: number;
|
||||
kilometerSystem?: KilometerSystem;
|
||||
TransponderRef?: RelatedRef;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@ -2969,6 +2970,9 @@ export namespace graphicData {
|
||||
if ("kilometerSystem" in data && data.kilometerSystem != undefined) {
|
||||
this.kilometerSystem = data.kilometerSystem;
|
||||
}
|
||||
if ("TransponderRef" in data && data.TransponderRef != undefined) {
|
||||
this.TransponderRef = data.TransponderRef;
|
||||
}
|
||||
}
|
||||
}
|
||||
get common() {
|
||||
@ -3007,12 +3011,22 @@ export namespace graphicData {
|
||||
get has_kilometerSystem() {
|
||||
return pb_1.Message.getField(this, 5) != null;
|
||||
}
|
||||
get TransponderRef() {
|
||||
return pb_1.Message.getWrapperField(this, RelatedRef, 6) as RelatedRef;
|
||||
}
|
||||
set TransponderRef(value: RelatedRef) {
|
||||
pb_1.Message.setWrapperField(this, 6, value);
|
||||
}
|
||||
get has_TransponderRef() {
|
||||
return pb_1.Message.getField(this, 6) != null;
|
||||
}
|
||||
static fromObject(data: {
|
||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
transponderType?: number;
|
||||
index?: number;
|
||||
kilometerSystem?: ReturnType<typeof KilometerSystem.prototype.toObject>;
|
||||
TransponderRef?: ReturnType<typeof RelatedRef.prototype.toObject>;
|
||||
}): Transponder {
|
||||
const message = new Transponder({});
|
||||
if (data.common != null) {
|
||||
@ -3030,6 +3044,9 @@ export namespace graphicData {
|
||||
if (data.kilometerSystem != null) {
|
||||
message.kilometerSystem = KilometerSystem.fromObject(data.kilometerSystem);
|
||||
}
|
||||
if (data.TransponderRef != null) {
|
||||
message.TransponderRef = RelatedRef.fromObject(data.TransponderRef);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
@ -3039,6 +3056,7 @@ export namespace graphicData {
|
||||
transponderType?: number;
|
||||
index?: number;
|
||||
kilometerSystem?: ReturnType<typeof KilometerSystem.prototype.toObject>;
|
||||
TransponderRef?: ReturnType<typeof RelatedRef.prototype.toObject>;
|
||||
} = {};
|
||||
if (this.common != null) {
|
||||
data.common = this.common.toObject();
|
||||
@ -3055,6 +3073,9 @@ export namespace graphicData {
|
||||
if (this.kilometerSystem != null) {
|
||||
data.kilometerSystem = this.kilometerSystem.toObject();
|
||||
}
|
||||
if (this.TransponderRef != null) {
|
||||
data.TransponderRef = this.TransponderRef.toObject();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@ -3071,6 +3092,8 @@ export namespace graphicData {
|
||||
writer.writeInt32(4, this.index);
|
||||
if (this.has_kilometerSystem)
|
||||
writer.writeMessage(5, this.kilometerSystem, () => this.kilometerSystem.serialize(writer));
|
||||
if (this.has_TransponderRef)
|
||||
writer.writeMessage(6, this.TransponderRef, () => this.TransponderRef.serialize(writer));
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@ -3095,6 +3118,9 @@ export namespace graphicData {
|
||||
case 5:
|
||||
reader.readMessage(message.kilometerSystem, () => message.kilometerSystem = KilometerSystem.deserialize(reader));
|
||||
break;
|
||||
case 6:
|
||||
reader.readMessage(message.TransponderRef, () => message.TransponderRef = RelatedRef.deserialize(reader));
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user