列车轮径调整

This commit is contained in:
dong 2023-11-13 15:08:32 +08:00
parent f81ef0204e
commit 440e2c096e
5 changed files with 156 additions and 94 deletions

View File

@ -16,7 +16,7 @@
type="number"
dense
outlined
:label="`列车偏移(mm)[长度${props.kmLength}mm]`"
:label="`列车偏移(mm)【长度${props.kmLength}mm】`"
:max="kmLength"
:min="0"
v-model.number="offset"
@ -41,6 +41,17 @@
:options="lengthOptions"
>
</q-select>
<q-input
type="number"
dense
outlined
label="列车轮径(mm)【长度770-840mm】"
:max="840"
:min="770"
v-model.number="wheelDiameter"
lazy-rules
:rules="wheelDiameterRules"
/>
<q-card-actions align="right" class="text-primary">
<q-btn flat label="取消" @click="onDialogCancel" v-close-popup />
<q-btn flat label="确认" type="submit" />
@ -68,6 +79,10 @@ const props = defineProps({
type: Number,
required: true,
},
wDiameter: {
type: Number,
default: 800,
},
});
const dir = ref(1);
const offset = ref(0);
@ -94,6 +109,7 @@ onMounted(() => {
if (mapId) {
getLengthOption(mapId);
}
wheelDiameter.value = props.wDiameter;
});
function getLengthOption(mapId: number) {
@ -117,9 +133,16 @@ function onCreate() {
dir: dir.value,
offset: offset.value,
trainLength: trainLength.value,
wheelDiameter: wheelDiameter.value,
});
}
});
}
const wheelDiameter = ref(800);
const wheelDiameterRules = [
(val: string) => (val !== null && val !== '') || '偏移量不能为空!',
(val: number) => (val >= 770 && val <= 840) || '列车轮径在770到840mm之间',
];
</script>
<style scoped></style>

View File

@ -252,29 +252,37 @@ export class SectionOperateInteraction extends GraphicInteractionPlugin<Section>
componentProps: { dev: section, kmLength: d },
cancel: true,
persistent: true,
}).onOk((data: { offset: number; dir: 1 | 0; trainLength: string }) => {
const params = {
simulationId,
mapId,
up: !!data.dir,
id: section.datas.id,
headOffset: data.offset,
};
if (data.trainLength) {
Object.assign(params, { trainLength: +data.trainLength });
}
addTrain(params)
.then(() => {
successNotify('添加列车成功!');
})
.catch((err) => {
const error = err as ApiError;
Notify.create({
type: 'negative',
message: `添加列车失败!: ${error.title}`,
}).onOk(
(data: {
offset: number;
dir: 1 | 0;
trainLength: string;
wheelDiameter: number;
}) => {
const params = {
simulationId,
mapId,
up: !!data.dir,
id: section.datas.id,
headOffset: data.offset,
wheelDiameter: data.wheelDiameter,
};
if (data.trainLength) {
Object.assign(params, { trainLength: +data.trainLength });
}
addTrain(params)
.then(() => {
successNotify('添加列车成功!');
})
.catch((err) => {
const error = err as ApiError;
Notify.create({
type: 'negative',
message: `添加列车失败!: ${error.title}`,
});
});
});
});
}
);
};
SectionOperateMenu.open(e.global);
}

View File

@ -151,30 +151,38 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> {
componentProps: { dev: turnout, kmLength: d },
cancel: true,
persistent: true,
}).onOk((data: { offset: number; dir: 1 | 0; trainLength: string }) => {
const params = {
simulationId,
mapId,
up: !!data.dir,
id: turnout.datas.id,
devicePort: port,
headOffset: data.offset,
};
if (data.trainLength) {
Object.assign(params, { trainLength: +data.trainLength });
}
addTrain(params)
.then(() => {
successNotify('添加列车成功!');
})
.catch((err) => {
const error = err as ApiError;
Notify.create({
type: 'negative',
message: `添加列车失败!: ${error.title}`,
}).onOk(
(data: {
offset: number;
dir: 1 | 0;
trainLength: string;
wheelDiameter: number;
}) => {
const params = {
simulationId,
mapId,
up: !!data.dir,
id: turnout.datas.id,
devicePort: port,
headOffset: data.offset,
wheelDiameter: data.wheelDiameter,
};
if (data.trainLength) {
Object.assign(params, { trainLength: +data.trainLength });
}
addTrain(params)
.then(() => {
successNotify('添加列车成功!');
})
.catch((err) => {
const error = err as ApiError;
Notify.create({
type: 'negative',
message: `添加列车失败!: ${error.title}`,
});
});
});
});
}
);
};
TurnoutOperationMenu.open(e.global);
}

View File

@ -66,14 +66,14 @@
<div class="text-h6">
{{ wheelEditInfo.id ? '编辑轮径' : '新建轮径' }}
</div>
<q-input
<!-- <q-input
outlined
label="轮径名称"
v-model="wheelEditInfo.name"
lazy-rules
:rules="[(val) => val.length > 0 || '请输入名称!']"
/>
<q-input
/> -->
<!-- <q-input
outlined
label="轮径安装轴位"
v-model.number="wheelEditInfo.axial_position"
@ -99,7 +99,7 @@
label="安装方向"
lazy-rules
:rules="[(val) => val.length > 0 || '请输入左侧或者右侧!']"
></q-select>
></q-select> -->
<q-input
outlined
@ -160,53 +160,53 @@ onMounted(() => {
wheelTableRef.value.requestServerInteraction();
});
const directionOptions = [
{ label: '左侧', value: 'LEFT' },
{ label: '右侧', value: 'RIGHT' },
];
function getDirectionName(val: string) {
let n = '';
if (val) {
const find = directionOptions.find((item) => {
return item.value == val;
});
n = find ? find.label : '';
}
return n;
}
// const directionOptions = [
// { label: '', value: 'LEFT' },
// { label: '', value: 'RIGHT' },
// ];
// function getDirectionName(val: string) {
// let n = '';
// if (val) {
// const find = directionOptions.find((item) => {
// return item.value == val;
// });
// n = find ? find.label : '';
// }
// return n;
// }
//
const wheelColumnDefs: QTableColumn[] = [
{
name: 'name',
label: '名称',
field: 'name',
required: true,
align: 'center',
},
{
name: 'axial_position',
label: '安装轴位',
field: 'axial_position',
required: true,
align: 'center',
},
{
name: 'diameter',
label: '车轮直径(mm)',
field: 'diameter',
required: true,
align: 'center',
},
{
name: 'install_direction',
label: '安装方向',
field: (row) => {
return getDirectionName(row.install_direction);
},
required: true,
align: 'center',
},
// {
// name: 'name',
// label: '',
// field: 'name',
// required: true,
// align: 'center',
// },
// {
// name: 'axial_position',
// label: '',
// field: 'axial_position',
// required: true,
// align: 'center',
// },
// {
// name: 'diameter',
// label: '(mm)',
// field: 'diameter',
// required: true,
// align: 'center',
// },
// {
// name: 'install_direction',
// label: '',
// field: (row) => {
// return getDirectionName(row.install_direction);
// },
// required: true,
// align: 'center',
// },
{
name: 'max_diameter',
label: '车轮的最大直径(mm)',

View File

@ -1015,6 +1015,7 @@ export namespace state {
vobcState?: TrainVobcState;
trainKilometer?: number;
controlDelayTime?: number;
wheelDiameter?: number;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -1064,6 +1065,9 @@ export namespace state {
if ("controlDelayTime" in data && data.controlDelayTime != undefined) {
this.controlDelayTime = data.controlDelayTime;
}
if ("wheelDiameter" in data && data.wheelDiameter != undefined) {
this.wheelDiameter = data.wheelDiameter;
}
}
}
get id() {
@ -1162,6 +1166,12 @@ export namespace state {
set controlDelayTime(value: number) {
pb_1.Message.setField(this, 15, value);
}
get wheelDiameter() {
return pb_1.Message.getFieldWithDefault(this, 16, 0) as number;
}
set wheelDiameter(value: number) {
pb_1.Message.setField(this, 16, value);
}
static fromObject(data: {
id?: string;
up?: boolean;
@ -1178,6 +1188,7 @@ export namespace state {
vobcState?: ReturnType<typeof TrainVobcState.prototype.toObject>;
trainKilometer?: number;
controlDelayTime?: number;
wheelDiameter?: number;
}): TrainState {
const message = new TrainState({});
if (data.id != null) {
@ -1225,6 +1236,9 @@ export namespace state {
if (data.controlDelayTime != null) {
message.controlDelayTime = data.controlDelayTime;
}
if (data.wheelDiameter != null) {
message.wheelDiameter = data.wheelDiameter;
}
return message;
}
toObject() {
@ -1244,6 +1258,7 @@ export namespace state {
vobcState?: ReturnType<typeof TrainVobcState.prototype.toObject>;
trainKilometer?: number;
controlDelayTime?: number;
wheelDiameter?: number;
} = {};
if (this.id != null) {
data.id = this.id;
@ -1290,6 +1305,9 @@ export namespace state {
if (this.controlDelayTime != null) {
data.controlDelayTime = this.controlDelayTime;
}
if (this.wheelDiameter != null) {
data.wheelDiameter = this.wheelDiameter;
}
return data;
}
serialize(): Uint8Array;
@ -1326,6 +1344,8 @@ export namespace state {
writer.writeInt64(14, this.trainKilometer);
if (this.controlDelayTime != 0)
writer.writeInt64(15, this.controlDelayTime);
if (this.wheelDiameter != 0)
writer.writeInt32(16, this.wheelDiameter);
if (!w)
return writer.getResultBuffer();
}
@ -1380,6 +1400,9 @@ export namespace state {
case 15:
message.controlDelayTime = reader.readInt64();
break;
case 16:
message.wheelDiameter = reader.readInt32();
break;
default: reader.skipField();
}
}