应答器接口及状态显示调整

This commit is contained in:
fan 2024-01-22 11:30:11 +08:00
parent 2a217ed2f3
commit f9e06c5f09
11 changed files with 161 additions and 72 deletions

@ -1 +1 @@
Subproject commit 3180214b105526abc5bc2c5ea67d431a38863c89
Subproject commit 3a30efc9fe949cd5ab9898073f00a093716f279e

View File

@ -275,7 +275,8 @@ export async function screenDoorOperate(data: {
export async function updateMessageTransponder(data: {
simulationId: string;
mapId: number;
telegram: string;
fixedTelegram: string;
fixedUserTelegram: string;
baliseId: number;
}) {
return await api.put(`${UriBase}/balise/telegram/modify`, data);

View File

@ -4,11 +4,11 @@
seamless
title="修改应答器报文"
v-model="showUpdateMessage"
:width="300"
:width="350"
:height="0"
>
<template v-slot:footer>
<q-card style="width: 300px">
<q-card style="width: 350px">
<q-card-section>
<q-form ref="myForm" @submit="onCreate" class="q-gutter-md">
<q-input
@ -21,7 +21,20 @@
<q-input
dense
outlined
label="报文"
label="固定用户报文"
autogrow
counter
:rules="[
(val) => {
return validateUserMessage(val);
},
]"
v-model="fixedUserTelegramData"
/>
<q-input
dense
outlined
label="固定报文"
autogrow
counter
:rules="[
@ -29,7 +42,7 @@
return validateMessage(val);
},
]"
v-model="message"
v-model="fixedTelegramData"
/>
<q-card-actions align="right" class="text-primary">
<q-btn
@ -64,15 +77,21 @@ const props = defineProps({
type: String,
required: true,
},
telegram: {
fixedTelegram: {
type: String,
required: true,
},
fixedUserTelegram: {
type: String,
required: true,
},
});
const showUpdateMessage = ref(true);
const message = ref('');
const fixedTelegramData = ref('');
const fixedUserTelegramData = ref('');
onMounted(() => {
message.value = props.telegram;
fixedTelegramData.value = props.fixedTelegram;
fixedUserTelegramData.value = props.fixedUserTelegram;
});
const myForm = ref<QForm | null>(null);
@ -85,7 +104,8 @@ function onCreate() {
simulationId,
mapId,
baliseId: props.id,
telegram: message.value,
fixedTelegram: fixedTelegramData.value,
fixedUserTelegram: fixedUserTelegramData.value,
}).catch((e) => errorNotify('修改应答器报文失败:' + e.title, e));
showUpdateMessage.value = false;
}
@ -96,6 +116,35 @@ onUnmounted(() => {
useLineStore().deviceOpreratDialogInstance = null;
});
function validateUserMessage(val: string) {
if (val.length !== 208) {
return '报文长度应为208个字符';
}
const list = [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F',
];
const falg = val.split('').some((elem) => !list.includes(elem));
if (falg) {
return '报文格式错误字符应为【0-F】的十六进制数';
} else {
return true;
}
}
function validateMessage(val: string) {
if (val.length !== 256) {
return '报文长度应为256个字符';

View File

@ -56,7 +56,7 @@
readonly
autogrow
v-model="transponderModel.userTelegram"
label="用户报文"
label="固定用户报文"
/>
<q-input
outlined
@ -64,7 +64,7 @@
readonly
autogrow
v-model="transponderModel.fixedTelegram"
label="报文"
label="固定报文"
/>
<q-field class="q-mt-md" outlined label="关联区段" readonly stack-label>
<template #control>

View File

@ -56,10 +56,18 @@
<q-input
outlined
style="margin-top: 10px"
v-model="telegram"
v-model="transponderState.fixedUserTelegram"
autogrow
readonly
label="报文"
label="固定用户报文"
/>
<q-input
outlined
style="margin-top: 10px"
v-model="transponderState.fixedTelegram"
autogrow
readonly
label="固定报文"
/>
</q-card-section>
</q-card>
@ -74,16 +82,13 @@ import MoveTransponder from 'src/components/draw-app/dialogs/MoveTransponder.vue
import UpdateMessageTransponder from 'src/components/draw-app/dialogs/UpdateMessageTransponder.vue';
import { Dialog } from 'quasar';
import {
updateMessageTransponder,
resetMessageTransponder,
updatePositionTransponder,
resetPositionTransponder,
} from 'src/api/Simulation';
const lineStore = useLineStore();
const transponderState = ref<TransponderState>(new TransponderState());
const code = ref('');
const telegram = ref('');
const kilometer = ref(0);
enum TransponderOperation {
MovePosition = 1,
@ -128,7 +133,6 @@ watch(
);
function initTransponderState(transponder: Transponder) {
code.value = transponder.datas.code;
telegram.value = transponder.states.telegram || '';
kilometer.value = transponder.states.km?.kilometer || 0;
transponderState.value = transponder.states.clone() as TransponderState;
}
@ -167,7 +171,8 @@ function doTransponderOperation(operation: number) {
component: UpdateMessageTransponder,
componentProps: {
code: code.value,
telegram: transponderState.value.telegram,
fixedTelegram: transponderState.value.fixedTelegram,
fixedUserTelegram: transponderState.value.fixedUserTelegram,
id: transponderState.value.id,
},
cancel: true,
@ -200,7 +205,6 @@ watch(
});
if (find) {
transponderState.value = find.clone() as TransponderState;
telegram.value = transponderState.value.telegram || '';
kilometer.value = transponderState.value.km.kilometer;
}
}

View File

@ -78,11 +78,11 @@ export class TransponderData
set fixedTelegram(v: string) {
this.data.fixedTelegram = v;
}
get userTelegram(): string {
return this.data.userTelegram;
get fixedUserTelegram(): string {
return this.data.fixedUserTelegram;
}
set userTelegram(v: string) {
this.data.userTelegram = v;
set fixedUserTelegram(v: string) {
this.data.fixedUserTelegram = v;
}
get type(): TransponderTypeEnum {
return this.data.type;
@ -146,11 +146,17 @@ export class TransponderState
set km(v: graphicData.KilometerSystem) {
this.states.km = new graphicData.KilometerSystem(v);
}
get telegram(): string {
return this.states.telegram;
get fixedTelegram(): string {
return this.states.fixedTelegram;
}
set telegram(v: string) {
this.states.telegram = v;
set fixedTelegram(v: string) {
this.states.fixedTelegram = v;
}
get fixedUserTelegram(): string {
return this.states.fixedUserTelegram;
}
set fixedUserTelegram(v: string) {
this.states.fixedUserTelegram = v;
}
get states(): state.BaliseState {
return this.getState<state.BaliseState>();
@ -239,7 +245,8 @@ export class TransponderOperationPlugin extends GraphicInteractionPlugin<Transpo
component: UpdateMessageTransponder,
componentProps: {
code: transponder.datas.code,
telegram: transponder.states.telegram,
fixedTelegram: transponder.states.fixedTelegram,
fixedUserTelegram: transponder.states.fixedUserTelegram,
id: transponder.datas.id
},
cancel: true,

View File

@ -33,8 +33,8 @@ export interface ITransponderData extends GraphicData {
set centralizedStations(v: number[]);
get fixedTelegram(): string; // 无源应答器固定报文
set fixedTelegram(v: string);
get userTelegram(): string;
set userTelegram(v: string);
get fixedUserTelegram(): string;
set fixedUserTelegram(v: string);
get type(): TransponderTypeEnum; // 应答器类型
set type(v: TransponderTypeEnum);
clone(): ITransponderData;
@ -45,7 +45,8 @@ export interface ITransponderData extends GraphicData {
export interface ITransponderState extends GraphicState {
id?: number;
km?: KilometerSystem;
telegram?: string;
fixedTelegram: string;
fixedUserTelegram: string
}
export enum TransponderTypeEnum {
@ -61,7 +62,7 @@ export const TransponderConsts = {
lineWidth: 2,
lineColor: '0xFFFFFF',
wblineColor: '0xFF0000',
textFontSize: 12,
textFontSize: 10,
textMarginY: 5, // 名称与应答器的距离
vblineColor: '0xFF00FF',
iblineColor: '0x0000FF',
@ -147,6 +148,10 @@ export class TransponderCode extends Container {
super();
this.addChild(this.codeText);
}
setVectorFontSize(fontSize: number) {
this.codeText.setVectorFontSize(fontSize)
}
clear() {
this.codeText.text = '';
}
@ -164,6 +169,7 @@ export class Transponder extends JlGraphic {
super(Transponder.Type);
this.addChild(this.polygonGraphic);
this.addChild(this.labelGraphic);
this.labelGraphic.setVectorFontSize(TransponderConsts.textFontSize);
}
get code(): string {
return this.datas.code;
@ -203,11 +209,7 @@ export class Transponder extends JlGraphic {
});
polygonGraphic.endFill;
this.labelGraphic.paint(this.datas);
const style = {
fill: lineColor,
fontSize: TransponderConsts.textFontSize,
};
this.labelGraphic.codeText.style = style;
this.labelGraphic.codeText.style.fill = lineColor;
const codeTransform = this.datas?.childTransforms?.find(
(item) => item.name === 'transponderCode'
);

View File

@ -143,13 +143,14 @@ function buildCodeAbsorbablePositions(
);
const canvas = transponder.getCanvas();
transponders.forEach((item) => {
const p = item.localToCanvasPoint({ x: item.labelGraphic.x, y: item.labelGraphic.y })
const ala = new AbsorbableLine(
new Point(item.x, 0),
new Point(item.x, canvas.height)
new Point(p.x, 0),
new Point(p.x, canvas.height)
);
const alb = new AbsorbableLine(
new Point(0, item.y),
new Point(canvas.width, item.y)
new Point(0, p.y),
new Point(canvas.width, p.y)
);
aps.push(ala);
aps.push(alb);

View File

@ -379,7 +379,7 @@ const leftMenuConfig = [
click: oneClickGenerateEsbCombinationData,
},
{
label: '一键添加应答器编号后缀(集中站简拼)',
label: '一键添加应答器后缀(集中站简拼)',
click: oneClickHandleTransponderCodeSuffix,
},
];
@ -964,7 +964,9 @@ function oneClickHandleTransponderCodeSuffix() {
.queryStore.queryById<Station>(trans.datas.centralizedStations[0])
.datas.stationNameAcronym;
if (stationNameAcronym) {
trans.datas.code = tc + '_' + stationNameAcronym;
const datas = trans.datas.clone();
datas.code = tc + '_' + stationNameAcronym;
trans.updateData(datas);
}
}
});

View File

@ -5547,7 +5547,8 @@ export namespace state {
constructor(data?: any[] | {
id?: number;
km?: dependency_1.graphicData.KilometerSystem;
telegram?: string;
fixedTelegram?: string;
fixedUserTelegram?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -5558,8 +5559,11 @@ export namespace state {
if ("km" in data && data.km != undefined) {
this.km = data.km;
}
if ("telegram" in data && data.telegram != undefined) {
this.telegram = data.telegram;
if ("fixedTelegram" in data && data.fixedTelegram != undefined) {
this.fixedTelegram = data.fixedTelegram;
}
if ("fixedUserTelegram" in data && data.fixedUserTelegram != undefined) {
this.fixedUserTelegram = data.fixedUserTelegram;
}
}
}
@ -5578,16 +5582,23 @@ export namespace state {
get has_km() {
return pb_1.Message.getField(this, 2) != null;
}
get telegram() {
get fixedTelegram() {
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
}
set telegram(value: string) {
set fixedTelegram(value: string) {
pb_1.Message.setField(this, 3, value);
}
get fixedUserTelegram() {
return pb_1.Message.getFieldWithDefault(this, 4, "") as string;
}
set fixedUserTelegram(value: string) {
pb_1.Message.setField(this, 4, value);
}
static fromObject(data: {
id?: number;
km?: ReturnType<typeof dependency_1.graphicData.KilometerSystem.prototype.toObject>;
telegram?: string;
fixedTelegram?: string;
fixedUserTelegram?: string;
}): BaliseState {
const message = new BaliseState({});
if (data.id != null) {
@ -5596,8 +5607,11 @@ export namespace state {
if (data.km != null) {
message.km = dependency_1.graphicData.KilometerSystem.fromObject(data.km);
}
if (data.telegram != null) {
message.telegram = data.telegram;
if (data.fixedTelegram != null) {
message.fixedTelegram = data.fixedTelegram;
}
if (data.fixedUserTelegram != null) {
message.fixedUserTelegram = data.fixedUserTelegram;
}
return message;
}
@ -5605,7 +5619,8 @@ export namespace state {
const data: {
id?: number;
km?: ReturnType<typeof dependency_1.graphicData.KilometerSystem.prototype.toObject>;
telegram?: string;
fixedTelegram?: string;
fixedUserTelegram?: string;
} = {};
if (this.id != null) {
data.id = this.id;
@ -5613,8 +5628,11 @@ export namespace state {
if (this.km != null) {
data.km = this.km.toObject();
}
if (this.telegram != null) {
data.telegram = this.telegram;
if (this.fixedTelegram != null) {
data.fixedTelegram = this.fixedTelegram;
}
if (this.fixedUserTelegram != null) {
data.fixedUserTelegram = this.fixedUserTelegram;
}
return data;
}
@ -5626,8 +5644,10 @@ export namespace state {
writer.writeUint32(1, this.id);
if (this.has_km)
writer.writeMessage(2, this.km, () => this.km.serialize(writer));
if (this.telegram.length)
writer.writeString(3, this.telegram);
if (this.fixedTelegram.length)
writer.writeString(3, this.fixedTelegram);
if (this.fixedUserTelegram.length)
writer.writeString(4, this.fixedUserTelegram);
if (!w)
return writer.getResultBuffer();
}
@ -5644,7 +5664,10 @@ export namespace state {
reader.readMessage(message.km, () => message.km = dependency_1.graphicData.KilometerSystem.deserialize(reader));
break;
case 3:
message.telegram = reader.readString();
message.fixedTelegram = reader.readString();
break;
case 4:
message.fixedUserTelegram = reader.readString();
break;
default: reader.skipField();
}

View File

@ -5088,7 +5088,7 @@ export namespace graphicData {
type?: Transponder.TransponderTypeEnum;
centralizedStations?: number[];
fixedTelegram?: string;
userTelegram?: string;
fixedUserTelegram?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [7, 10], this.#one_of_decls);
@ -5117,8 +5117,8 @@ export namespace graphicData {
if ("fixedTelegram" in data && data.fixedTelegram != undefined) {
this.fixedTelegram = data.fixedTelegram;
}
if ("userTelegram" in data && data.userTelegram != undefined) {
this.userTelegram = data.userTelegram;
if ("fixedUserTelegram" in data && data.fixedUserTelegram != undefined) {
this.fixedUserTelegram = data.fixedUserTelegram;
}
}
}
@ -5179,10 +5179,10 @@ export namespace graphicData {
set fixedTelegram(value: string) {
pb_1.Message.setField(this, 11, value);
}
get userTelegram() {
get fixedUserTelegram() {
return pb_1.Message.getFieldWithDefault(this, 12, "") as string;
}
set userTelegram(value: string) {
set fixedUserTelegram(value: string) {
pb_1.Message.setField(this, 12, value);
}
static fromObject(data: {
@ -5194,7 +5194,7 @@ export namespace graphicData {
type?: Transponder.TransponderTypeEnum;
centralizedStations?: number[];
fixedTelegram?: string;
userTelegram?: string;
fixedUserTelegram?: string;
}): Transponder {
const message = new Transponder({});
if (data.common != null) {
@ -5221,8 +5221,8 @@ export namespace graphicData {
if (data.fixedTelegram != null) {
message.fixedTelegram = data.fixedTelegram;
}
if (data.userTelegram != null) {
message.userTelegram = data.userTelegram;
if (data.fixedUserTelegram != null) {
message.fixedUserTelegram = data.fixedUserTelegram;
}
return message;
}
@ -5236,7 +5236,7 @@ export namespace graphicData {
type?: Transponder.TransponderTypeEnum;
centralizedStations?: number[];
fixedTelegram?: string;
userTelegram?: string;
fixedUserTelegram?: string;
} = {};
if (this.common != null) {
data.common = this.common.toObject();
@ -5262,8 +5262,8 @@ export namespace graphicData {
if (this.fixedTelegram != null) {
data.fixedTelegram = this.fixedTelegram;
}
if (this.userTelegram != null) {
data.userTelegram = this.userTelegram;
if (this.fixedUserTelegram != null) {
data.fixedUserTelegram = this.fixedUserTelegram;
}
return data;
}
@ -5287,8 +5287,8 @@ export namespace graphicData {
writer.writePackedUint32(10, this.centralizedStations);
if (this.fixedTelegram.length)
writer.writeString(11, this.fixedTelegram);
if (this.userTelegram.length)
writer.writeString(12, this.userTelegram);
if (this.fixedUserTelegram.length)
writer.writeString(12, this.fixedUserTelegram);
if (!w)
return writer.getResultBuffer();
}
@ -5323,7 +5323,7 @@ export namespace graphicData {
message.fixedTelegram = reader.readString();
break;
case 12:
message.userTelegram = reader.readString();
message.fixedUserTelegram = reader.readString();
break;
default: reader.skipField();
}