区段常规运行方向生成规则修改

This commit is contained in:
Yuan 2023-12-05 13:37:00 +08:00
parent 3e5dd10165
commit b174bc0fb2
7 changed files with 121 additions and 52 deletions

@ -1 +1 @@
Subproject commit 89944562247f061937fde4c8a67285f64c55aefa
Subproject commit 0a6fdf768814f03bc563aa79aeb4a2664cc5d9e5

View File

@ -18,11 +18,22 @@ const sectionCode = computed(() => {
return '';
});
const formRef = ref<InstanceType<typeof QForm> | null>(null);
const direction = ref(0);
const directionOptions = [
const runningDirection = ref(0);
const runningDirectionOptions = [
{ label: 'A到B', value: graphicData.Section.RunningDirection.AtoB },
{ label: 'B到A', value: graphicData.Section.RunningDirection.BtoA },
];
const direction = ref(0);
const directionOptions = [
{
label: '上行',
value: graphicData.Direction.UP,
},
{
label: '下行',
value: graphicData.Direction.DOWN,
},
];
async function onSubmit() {
const res = await formRef.value?.validate();
@ -33,8 +44,8 @@ async function onSubmit() {
const queue: {
node: Section | Turnout;
direction: graphicData.Section.RunningDirection;
}[] = [{ node: section, direction: direction.value }];
runningDirection: graphicData.Section.RunningDirection;
}[] = [{ node: section, runningDirection: runningDirection.value }];
const reverseDirection = (d: graphicData.Section.RunningDirection) =>
d === graphicData.Section.RunningDirection.AtoB
@ -43,7 +54,7 @@ async function onSubmit() {
const traverse = (
current: Section | Turnout,
direction: graphicData.Section.RunningDirection
runningDirection: graphicData.Section.RunningDirection
) => {
if (visited.includes(current.datas.id)) return;
visited.push(current.datas.id);
@ -53,12 +64,12 @@ async function onSubmit() {
[current.datas.pbRef?.id, 'B'],
]
.filter((item): item is [string, 'A' | 'B'] => !!item[0])
.forEach(([id, port], idx) => {
.forEach(([id, port]) => {
const target = current.queryStore.queryById<Section | Turnout>(id);
if (target instanceof Turnout) {
queue.push({
node: target,
direction,
runningDirection,
});
} else {
const isPortDiffrent =
@ -66,46 +77,32 @@ async function onSubmit() {
(port === 'A' && target.datas.pbRef?.id === current.datas.id);
queue.push({
node: target,
direction: isPortDiffrent
? direction
: reverseDirection(direction),
runningDirection: isPortDiffrent
? runningDirection
: reverseDirection(runningDirection),
});
}
});
const data = current.datas.clone();
data.normalRunningDirection = direction;
data.normalRunningDirection = runningDirection;
data.direction = direction.value;
current.updateData(data);
} else {
[
current.datas.paRef?.id,
current.datas.pbRef?.id,
current.datas.pcRef?.id,
]
[current.datas.paRef?.id, current.datas.pbRef?.id]
.filter((id): id is string => !!id)
.forEach((id, idx) => {
.forEach((id) => {
const target = current.queryStore.queryById<Section | Turnout>(id);
if (
target instanceof Turnout &&
target.datas.pcRef?.id === current.datas.id &&
idx === 2
) {
queue.push({
node: target,
direction: reverseDirection(direction),
});
} else {
queue.push({
node: target,
direction,
});
}
queue.push({
node: target,
runningDirection,
});
});
}
};
do {
const { node, direction } = queue.shift()!;
traverse(node, direction);
const { node, runningDirection } = queue.shift()!;
traverse(node, runningDirection);
} while (queue.length > 0);
}
</script>
@ -134,6 +131,15 @@ async function onSubmit() {
outlined
label="运行方向"
hint="请选择区段的常规运行方向"
v-model="runningDirection"
:options="runningDirectionOptions"
emit-value
map-options
/>
<QSelect
outlined
label="上下行方向"
hint="请选择区段的上下行方向"
v-model="direction"
:options="directionOptions"
emit-value

View File

@ -34,6 +34,16 @@
@blur="onUpdate"
label="常规运行方向"
></q-select>
<q-select
outlined
class="q-mt-lg"
v-model="sectionModel.direction"
:options="directionOptions"
emit-value
map-options
@blur="onUpdate"
label="上下行方向"
></q-select>
<q-checkbox
v-if="
sectionModel.sectionType === graphicData.Section.SectionType.Physical
@ -149,7 +159,7 @@ const sectionTypeText = computed(() => {
return ['物理区段', '', '道岔物理区段'][sectionModel.sectionType];
});
const runningDirectionOptions = computed(() => [
const runningDirectionOptions = [
{
label: 'A到B',
value: graphicData.Section.RunningDirection.AtoB,
@ -158,7 +168,22 @@ const runningDirectionOptions = computed(() => [
label: 'B到A',
value: graphicData.Section.RunningDirection.BtoA,
},
]);
{
label: '双向',
value: graphicData.Section.RunningDirection.BOTH,
},
];
const directionOptions = [
{
label: '上行',
value: graphicData.Direction.UP,
},
{
label: '下行',
value: graphicData.Direction.DOWN,
},
];
const sectionRelations = computed(() => {
const section = drawStore.selectedGraphic as Section;

View File

@ -115,6 +115,12 @@ export class SectionData extends GraphicDataBase implements ISectionData {
set isTurnBackZone(v: boolean) {
this.data.isTurnBackZone = v;
}
get direction(): graphicData.Direction {
return this.data.direction;
}
set direction(v: graphicData.Direction) {
this.data.direction = v;
}
clone(): SectionData {
return new SectionData(this.data.cloneMessage());
}

View File

@ -62,6 +62,8 @@ export interface ISectionData extends GraphicData {
set normalRunningDirection(v: graphicData.Section.RunningDirection);
get isTurnBackZone(): boolean;
set isTurnBackZone(v: boolean);
get direction(): graphicData.Direction;
set direction(v: graphicData.Direction);
clone(): ISectionData;
copyFrom(data: ISectionData): void;
eq(other: ISectionData): boolean;

View File

@ -104,11 +104,11 @@ export class OneClickGenerateDraw extends GraphicDrawAssistant<
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
kilometer: elem.datas.kilometerSystem.kilometer,
coordinateSystem: elem.datas.kilometerSystem.coordinateSystem,
direction: graphicData.Direction.LEFT,
direction: graphicData.KilometerSystem.Direction.LEFT,
});
} else {
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
direction: graphicData.Direction.LEFT,
direction: graphicData.KilometerSystem.Direction.LEFT,
});
}
} else {
@ -116,11 +116,11 @@ export class OneClickGenerateDraw extends GraphicDrawAssistant<
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
kilometer: elem.datas.kilometerSystem.kilometer,
coordinateSystem: elem.datas.kilometerSystem.coordinateSystem,
direction: graphicData.Direction.RIGHT,
direction: graphicData.KilometerSystem.Direction.RIGHT,
});
} else {
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
direction: graphicData.Direction.RIGHT,
direction: graphicData.KilometerSystem.Direction.RIGHT,
});
}
}
@ -138,14 +138,14 @@ export class OneClickGenerateDraw extends GraphicDrawAssistant<
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
kilometer: ks.kilometer,
coordinateSystem: ks.coordinateSystem,
direction: graphicData.Direction.LEFT,
direction: graphicData.KilometerSystem.Direction.LEFT,
});
} else {
const ks = elem.datas.kilometerSystem;
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
kilometer: ks.kilometer,
coordinateSystem: ks.coordinateSystem,
direction: graphicData.Direction.RIGHT,
direction: graphicData.KilometerSystem.Direction.RIGHT,
});
}
}

View File

@ -6,8 +6,8 @@
import * as pb_1 from "google-protobuf";
export namespace graphicData {
export enum Direction {
LEFT = 0,
RIGHT = 1
UP = 0,
DOWN = 1
}
export class RtssGraphicStorage extends pb_1.Message {
#one_of_decls: number[][] = [];
@ -3505,7 +3505,7 @@ export namespace graphicData {
constructor(data?: any[] | {
kilometer?: number;
coordinateSystem?: string;
direction?: Direction;
direction?: KilometerSystem.Direction;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -3534,15 +3534,15 @@ export namespace graphicData {
pb_1.Message.setField(this, 2, value);
}
get direction() {
return pb_1.Message.getFieldWithDefault(this, 3, Direction.LEFT) as Direction;
return pb_1.Message.getFieldWithDefault(this, 3, KilometerSystem.Direction.LEFT) as KilometerSystem.Direction;
}
set direction(value: Direction) {
set direction(value: KilometerSystem.Direction) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
kilometer?: number;
coordinateSystem?: string;
direction?: Direction;
direction?: KilometerSystem.Direction;
}): KilometerSystem {
const message = new KilometerSystem({});
if (data.kilometer != null) {
@ -3560,7 +3560,7 @@ export namespace graphicData {
const data: {
kilometer?: number;
coordinateSystem?: string;
direction?: Direction;
direction?: KilometerSystem.Direction;
} = {};
if (this.kilometer != null) {
data.kilometer = this.kilometer;
@ -3581,7 +3581,7 @@ export namespace graphicData {
writer.writeInt64(1, this.kilometer);
if (this.coordinateSystem.length)
writer.writeString(2, this.coordinateSystem);
if (this.direction != Direction.LEFT)
if (this.direction != KilometerSystem.Direction.LEFT)
writer.writeEnum(3, this.direction);
if (!w)
return writer.getResultBuffer();
@ -3613,6 +3613,12 @@ export namespace graphicData {
return KilometerSystem.deserialize(bytes);
}
}
export namespace KilometerSystem {
export enum Direction {
LEFT = 0,
RIGHT = 1
}
}
export class Signal extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
@ -3855,6 +3861,7 @@ export namespace graphicData {
centralizedStations?: string[];
normalRunningDirection?: Section.RunningDirection;
isTurnBackZone?: boolean;
direction?: Direction;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 7, 13], this.#one_of_decls);
@ -3898,6 +3905,9 @@ export namespace graphicData {
if ("isTurnBackZone" in data && data.isTurnBackZone != undefined) {
this.isTurnBackZone = data.isTurnBackZone;
}
if ("direction" in data && data.direction != undefined) {
this.direction = data.direction;
}
}
}
get common() {
@ -3987,6 +3997,12 @@ export namespace graphicData {
set isTurnBackZone(value: boolean) {
pb_1.Message.setField(this, 15, value);
}
get direction() {
return pb_1.Message.getFieldWithDefault(this, 16, Direction.UP) as Direction;
}
set direction(value: Direction) {
pb_1.Message.setField(this, 16, value);
}
static fromObject(data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
code?: string;
@ -4001,6 +4017,7 @@ export namespace graphicData {
centralizedStations?: string[];
normalRunningDirection?: Section.RunningDirection;
isTurnBackZone?: boolean;
direction?: Direction;
}): Section {
const message = new Section({});
if (data.common != null) {
@ -4042,6 +4059,9 @@ export namespace graphicData {
if (data.isTurnBackZone != null) {
message.isTurnBackZone = data.isTurnBackZone;
}
if (data.direction != null) {
message.direction = data.direction;
}
return message;
}
toObject() {
@ -4059,6 +4079,7 @@ export namespace graphicData {
centralizedStations?: string[];
normalRunningDirection?: Section.RunningDirection;
isTurnBackZone?: boolean;
direction?: Direction;
} = {};
if (this.common != null) {
data.common = this.common.toObject();
@ -4099,6 +4120,9 @@ export namespace graphicData {
if (this.isTurnBackZone != null) {
data.isTurnBackZone = this.isTurnBackZone;
}
if (this.direction != null) {
data.direction = this.direction;
}
return data;
}
serialize(): Uint8Array;
@ -4131,6 +4155,8 @@ export namespace graphicData {
writer.writeEnum(14, this.normalRunningDirection);
if (this.isTurnBackZone != false)
writer.writeBool(15, this.isTurnBackZone);
if (this.direction != Direction.UP)
writer.writeEnum(16, this.direction);
if (!w)
return writer.getResultBuffer();
}
@ -4179,6 +4205,9 @@ export namespace graphicData {
case 15:
message.isTurnBackZone = reader.readBool();
break;
case 16:
message.direction = reader.readEnum();
break;
default: reader.skipField();
}
}
@ -4198,7 +4227,8 @@ export namespace graphicData {
}
export enum RunningDirection {
AtoB = 0,
BtoA = 1
BtoA = 1,
BOTH = 2
}
}
export class RelatedRef extends pb_1.Message {