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

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: { export async function updateMessageTransponder(data: {
simulationId: string; simulationId: string;
mapId: number; mapId: number;
telegram: string; fixedTelegram: string;
fixedUserTelegram: string;
baliseId: number; baliseId: number;
}) { }) {
return await api.put(`${UriBase}/balise/telegram/modify`, data); return await api.put(`${UriBase}/balise/telegram/modify`, data);

View File

@ -4,11 +4,11 @@
seamless seamless
title="修改应答器报文" title="修改应答器报文"
v-model="showUpdateMessage" v-model="showUpdateMessage"
:width="300" :width="350"
:height="0" :height="0"
> >
<template v-slot:footer> <template v-slot:footer>
<q-card style="width: 300px"> <q-card style="width: 350px">
<q-card-section> <q-card-section>
<q-form ref="myForm" @submit="onCreate" class="q-gutter-md"> <q-form ref="myForm" @submit="onCreate" class="q-gutter-md">
<q-input <q-input
@ -21,7 +21,20 @@
<q-input <q-input
dense dense
outlined outlined
label="报文" label="固定用户报文"
autogrow
counter
:rules="[
(val) => {
return validateUserMessage(val);
},
]"
v-model="fixedUserTelegramData"
/>
<q-input
dense
outlined
label="固定报文"
autogrow autogrow
counter counter
:rules="[ :rules="[
@ -29,7 +42,7 @@
return validateMessage(val); return validateMessage(val);
}, },
]" ]"
v-model="message" v-model="fixedTelegramData"
/> />
<q-card-actions align="right" class="text-primary"> <q-card-actions align="right" class="text-primary">
<q-btn <q-btn
@ -64,15 +77,21 @@ const props = defineProps({
type: String, type: String,
required: true, required: true,
}, },
telegram: { fixedTelegram: {
type: String,
required: true,
},
fixedUserTelegram: {
type: String, type: String,
required: true, required: true,
}, },
}); });
const showUpdateMessage = ref(true); const showUpdateMessage = ref(true);
const message = ref(''); const fixedTelegramData = ref('');
const fixedUserTelegramData = ref('');
onMounted(() => { onMounted(() => {
message.value = props.telegram; fixedTelegramData.value = props.fixedTelegram;
fixedUserTelegramData.value = props.fixedUserTelegram;
}); });
const myForm = ref<QForm | null>(null); const myForm = ref<QForm | null>(null);
@ -85,7 +104,8 @@ function onCreate() {
simulationId, simulationId,
mapId, mapId,
baliseId: props.id, baliseId: props.id,
telegram: message.value, fixedTelegram: fixedTelegramData.value,
fixedUserTelegram: fixedUserTelegramData.value,
}).catch((e) => errorNotify('修改应答器报文失败:' + e.title, e)); }).catch((e) => errorNotify('修改应答器报文失败:' + e.title, e));
showUpdateMessage.value = false; showUpdateMessage.value = false;
} }
@ -96,6 +116,35 @@ onUnmounted(() => {
useLineStore().deviceOpreratDialogInstance = null; 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) { function validateMessage(val: string) {
if (val.length !== 256) { if (val.length !== 256) {
return '报文长度应为256个字符'; return '报文长度应为256个字符';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -379,7 +379,7 @@ const leftMenuConfig = [
click: oneClickGenerateEsbCombinationData, click: oneClickGenerateEsbCombinationData,
}, },
{ {
label: '一键添加应答器编号后缀(集中站简拼)', label: '一键添加应答器后缀(集中站简拼)',
click: oneClickHandleTransponderCodeSuffix, click: oneClickHandleTransponderCodeSuffix,
}, },
]; ];
@ -964,7 +964,9 @@ function oneClickHandleTransponderCodeSuffix() {
.queryStore.queryById<Station>(trans.datas.centralizedStations[0]) .queryStore.queryById<Station>(trans.datas.centralizedStations[0])
.datas.stationNameAcronym; .datas.stationNameAcronym;
if (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[] | { constructor(data?: any[] | {
id?: number; id?: number;
km?: dependency_1.graphicData.KilometerSystem; km?: dependency_1.graphicData.KilometerSystem;
telegram?: string; fixedTelegram?: string;
fixedUserTelegram?: string;
}) { }) {
super(); super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); 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) { if ("km" in data && data.km != undefined) {
this.km = data.km; this.km = data.km;
} }
if ("telegram" in data && data.telegram != undefined) { if ("fixedTelegram" in data && data.fixedTelegram != undefined) {
this.telegram = data.telegram; 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() { get has_km() {
return pb_1.Message.getField(this, 2) != null; return pb_1.Message.getField(this, 2) != null;
} }
get telegram() { get fixedTelegram() {
return pb_1.Message.getFieldWithDefault(this, 3, "") as string; return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
} }
set telegram(value: string) { set fixedTelegram(value: string) {
pb_1.Message.setField(this, 3, value); 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: { static fromObject(data: {
id?: number; id?: number;
km?: ReturnType<typeof dependency_1.graphicData.KilometerSystem.prototype.toObject>; km?: ReturnType<typeof dependency_1.graphicData.KilometerSystem.prototype.toObject>;
telegram?: string; fixedTelegram?: string;
fixedUserTelegram?: string;
}): BaliseState { }): BaliseState {
const message = new BaliseState({}); const message = new BaliseState({});
if (data.id != null) { if (data.id != null) {
@ -5596,8 +5607,11 @@ export namespace state {
if (data.km != null) { if (data.km != null) {
message.km = dependency_1.graphicData.KilometerSystem.fromObject(data.km); message.km = dependency_1.graphicData.KilometerSystem.fromObject(data.km);
} }
if (data.telegram != null) { if (data.fixedTelegram != null) {
message.telegram = data.telegram; message.fixedTelegram = data.fixedTelegram;
}
if (data.fixedUserTelegram != null) {
message.fixedUserTelegram = data.fixedUserTelegram;
} }
return message; return message;
} }
@ -5605,7 +5619,8 @@ export namespace state {
const data: { const data: {
id?: number; id?: number;
km?: ReturnType<typeof dependency_1.graphicData.KilometerSystem.prototype.toObject>; km?: ReturnType<typeof dependency_1.graphicData.KilometerSystem.prototype.toObject>;
telegram?: string; fixedTelegram?: string;
fixedUserTelegram?: string;
} = {}; } = {};
if (this.id != null) { if (this.id != null) {
data.id = this.id; data.id = this.id;
@ -5613,8 +5628,11 @@ export namespace state {
if (this.km != null) { if (this.km != null) {
data.km = this.km.toObject(); data.km = this.km.toObject();
} }
if (this.telegram != null) { if (this.fixedTelegram != null) {
data.telegram = this.telegram; data.fixedTelegram = this.fixedTelegram;
}
if (this.fixedUserTelegram != null) {
data.fixedUserTelegram = this.fixedUserTelegram;
} }
return data; return data;
} }
@ -5626,8 +5644,10 @@ export namespace state {
writer.writeUint32(1, this.id); writer.writeUint32(1, this.id);
if (this.has_km) if (this.has_km)
writer.writeMessage(2, this.km, () => this.km.serialize(writer)); writer.writeMessage(2, this.km, () => this.km.serialize(writer));
if (this.telegram.length) if (this.fixedTelegram.length)
writer.writeString(3, this.telegram); writer.writeString(3, this.fixedTelegram);
if (this.fixedUserTelegram.length)
writer.writeString(4, this.fixedUserTelegram);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -5644,7 +5664,10 @@ export namespace state {
reader.readMessage(message.km, () => message.km = dependency_1.graphicData.KilometerSystem.deserialize(reader)); reader.readMessage(message.km, () => message.km = dependency_1.graphicData.KilometerSystem.deserialize(reader));
break; break;
case 3: case 3:
message.telegram = reader.readString(); message.fixedTelegram = reader.readString();
break;
case 4:
message.fixedUserTelegram = reader.readString();
break; break;
default: reader.skipField(); default: reader.skipField();
} }

View File

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