diff --git a/src/api/RunconfigApi.ts b/src/api/RunconfigApi.ts index 16a899d..5e7f9cc 100644 --- a/src/api/RunconfigApi.ts +++ b/src/api/RunconfigApi.ts @@ -85,6 +85,9 @@ export enum typeStr { string = 'string', int = 'int', bool = 'bool', + uint8 = 'uint8', + uint16 = 'uint16', + uint32 = 'uint32', } export interface Description { diff --git a/src/components/ConfigData.vue b/src/components/ConfigData.vue index 2d2ba51..d5db332 100644 --- a/src/components/ConfigData.vue +++ b/src/components/ConfigData.vue @@ -7,12 +7,24 @@
- + + +
{{ menu.description }}
+
+ + + +
@@ -50,7 +63,14 @@ dense type="number" v-model.number="menu.val" - v-else-if="menu.type == typeStr.int" + v-else-if=" + [ + typeStr.int, + typeStr.uint8, + typeStr.uint16, + typeStr.uint32, + ].includes(menu.type) + " /> (); const menu = reactive({ fieldName: '', diff --git a/src/components/draw-app/properties/AxleCountingConfig.vue b/src/components/draw-app/properties/AxleCountingConfig.vue new file mode 100644 index 0000000..a3da85f --- /dev/null +++ b/src/components/draw-app/properties/AxleCountingConfig.vue @@ -0,0 +1,219 @@ + + + diff --git a/src/components/line-app/states/TurnoutState.vue b/src/components/line-app/states/TurnoutState.vue index 4984623..259af15 100644 --- a/src/components/line-app/states/TurnoutState.vue +++ b/src/components/line-app/states/TurnoutState.vue @@ -204,34 +204,43 @@ diff --git a/src/drawApp/commonApp.ts b/src/drawApp/commonApp.ts index 09e1881..5d20f25 100644 --- a/src/drawApp/commonApp.ts +++ b/src/drawApp/commonApp.ts @@ -221,6 +221,7 @@ export function initCommonDrawApp(app: IDrawApp) { app.on('destroy', async () => { UniqueIdPrefix = new graphicData.UniqueIdOfStationLayout(); screenDoorConfig = new graphicData.ScreenDoorConfig(); + generateAxleCountingConfig = new graphicData.GenerateAxleCountingConfig(); kilometerConvertList = []; sectionCodePointList = []; }); @@ -232,6 +233,7 @@ export function loadCommonDrawDatas( const datas: GraphicData[] = []; UniqueIdPrefix = storage.UniqueIdPrefix; screenDoorConfig = storage.screenDoorConfig; + generateAxleCountingConfig = storage.generateAxleCountingConfig; kilometerConvertList = storage.kilometerConvertList; sectionCodePointList = storage.sectionCodePointList; storage.Platforms.forEach((platform) => { @@ -368,6 +370,7 @@ export function saveCommonDrawDatas( } storage.UniqueIdPrefix = UniqueIdPrefix; storage.screenDoorConfig = screenDoorConfig; + storage.generateAxleCountingConfig = generateAxleCountingConfig; storage.kilometerConvertList = kilometerConvertList; storage.sectionCodePointList = sectionCodePointList; return storage; @@ -491,3 +494,15 @@ export function setScreenDoorConfig( ) { screenDoorConfig = newScreenDoorConfig; } + +//一键生成计轴配置 +let generateAxleCountingConfig = new graphicData.GenerateAxleCountingConfig(); +export function loadGenerateAxleCountingConfig() { + return generateAxleCountingConfig; +} + +export function setGenerateAxleCountingConfig( + newScreenDoorConfig: graphicData.GenerateAxleCountingConfig +) { + generateAxleCountingConfig = newScreenDoorConfig; +} diff --git a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts index 7e3541e..6931f49 100644 --- a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts +++ b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts @@ -19,6 +19,7 @@ import { Section, SectionPort, SectionType } from '../section/Section'; import { Turnout, TurnoutPort } from '../turnout/Turnout'; import { IRelatedRefData, createRelatedRefProto } from '../CommonGraphics'; import { Signal } from '../signal/Signal'; +import { loadGenerateAxleCountingConfig } from 'src/drawApp/commonApp'; export interface IAxleCountingDrawOptions { newData: () => IAxleCountingData; @@ -79,12 +80,39 @@ export class AxleCountingDraw extends GraphicDrawAssistant< refGraphic: Section | Turnout, refPort: TurnoutPort | SectionPort ) { + const generateAxleCountingConfig = loadGenerateAxleCountingConfig(); + if (generateAxleCountingConfig?.noGenerateGroup !== undefined) { + const noGenerateGroup = generateAxleCountingConfig.noGenerateGroup; + for (let i = 0; i < noGenerateGroup.length; i++) { + if ( + noGenerateGroup[i] == graphic.id && + ((i % 2 == 0 && refGraphic.id == noGenerateGroup[i + 1]) || + (i % 2 == 1 && refGraphic.id == noGenerateGroup[i - 1])) + ) { + map.set(`${graphic.id}-${port}`, 1); + map.set(`${refGraphic.id}-${refPort}`, 1); + return; + } + } + } if ( graphic.type == 'Turnout' && reftype == 'Turnout' && port == TurnoutPort.B && refPort == TurnoutPort.B ) { + //查看生成计轴bb配置 + let hasBB = false; + if (generateAxleCountingConfig !== undefined) { + const bbConnect = generateAxleCountingConfig.bbConnect; + if ( + bbConnect.includes(graphic.id) || + bbConnect.includes(refGraphic.id) + ) { + hasBB = true; + } + } + //bb连接处有信号机需要生成 const points = (graphic as Turnout).getPortPoints(); const portPs = graphic.localToCanvasPoints(points[1][0])[0]; let hasSingle = false; @@ -94,7 +122,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant< hasSingle = true; } }); - if (!hasSingle) { + if (!hasSingle && !hasBB) { map.set(`${graphic.id}-${port}`, 1); map.set(`${refGraphic.id}-${refPort}`, 1); return; diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index 74af3d9..06abb2e 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -59,7 +59,6 @@ + @@ -300,6 +303,7 @@ import SectionCodePointConfig from 'src/components/draw-app/properties/SectionCo import StationRelateDeviceConfig from 'src/components/draw-app/properties/StationRelateDeviceConfig.vue'; import StationRelateDeviceList from 'src/components/draw-app/dialogs/StationRelateDeviceList.vue'; import ScreenDoorConfig from 'src/components/draw-app/properties/ScreenDoorConfig.vue'; +import AxleCountingConfig from 'src/components/draw-app/properties/AxleCountingConfig.vue'; import { PictureType } from 'src/protos/picture'; import { Beacon } from 'src/graphics/beacon/Beacon'; @@ -394,11 +398,19 @@ const showScreenDoorConfig = ref(false); const closeScreenDoorConfig = () => { showScreenDoorConfig.value = false; }; +const showGenerateAxleCountingConfig = ref(false); +const closeGenerateAxleCountingConfig = () => { + showGenerateAxleCountingConfig.value = false; +}; const dataManageConfig = [ { label: '关联设备列表', click: openDeviceRelateList }, { label: '公里标转换', click: openkilometerConvertList }, { label: '区段码位列表', click: openSectionCodePointList }, { label: '屏蔽门配置', click: () => (showScreenDoorConfig.value = true) }, + { + label: '一键生成计轴配置', + click: () => (showGenerateAxleCountingConfig.value = true), + }, ]; onMounted(() => { @@ -428,20 +440,7 @@ onMounted(() => { EsbButton.Type, SlopeKiloMarker.Type, CurvatureKiloMarker.Type, - Beacon.Type, ]; - drawAssistantsTypes.forEach((type) => { - const drawAssistant = drawStore.getDrawApp().getDrawAssistant(type); - if (drawAssistant) { - utilsOption.push( - new ControlItem( - drawAssistant.name, - drawAssistant.icon, - drawAssistant.description || drawAssistant.name - ) - ); - } - }); switch (drawStore.categoryType) { case CategoryType.TH: leftMenuConfig.push( @@ -460,7 +459,22 @@ onMounted(() => { { label: '一键生成逻辑区段', click: oneClickLogicSection } ); break; + case CategoryType.ZDWX: + drawAssistantsTypes.push(Beacon.Type); + break; } + drawAssistantsTypes.forEach((type) => { + const drawAssistant = drawStore.getDrawApp().getDrawAssistant(type); + if (drawAssistant) { + utilsOption.push( + new ControlItem( + drawAssistant.name, + drawAssistant.icon, + drawAssistant.description || drawAssistant.name + ) + ); + } + }); }); const canvasWidth = ref(0); diff --git a/src/pages/RunconfigManage.vue b/src/pages/RunconfigManage.vue index e29e474..674752d 100644 --- a/src/pages/RunconfigManage.vue +++ b/src/pages/RunconfigManage.vue @@ -74,6 +74,7 @@ indicator-color="primary" align="justify" narrow-indicator + outside-arrows >
- +
@@ -356,6 +361,9 @@ const valObj = { string: '', int: 0, bool: false, + uint8: 0, + uint16: 0, + uint32: 0, }; function getObjData(fieldInfo: Description, obj: obj) { const key = fieldInfo.fieldName; @@ -379,8 +387,15 @@ function getObjData(fieldInfo: Description, obj: obj) { obj[key] = fieldInfo.val; } } +const basicsType = [ + typeStr.string, + typeStr.int, + typeStr.bool, + typeStr.uint8, + typeStr.uint16, + typeStr.uint32, +]; function setDefaultVal(fieldInfo: Description) { - const arr = ['string', 'int', 'bool']; if (fieldInfo.itemTypeFields) { if (fieldInfo.type == typeStr.array) { delete fieldInfo.val; @@ -389,7 +404,7 @@ function setDefaultVal(fieldInfo: Description) { setDefaultVal(ii); }); } else { - if (arr.includes(fieldInfo.type)) { + if (basicsType.includes(fieldInfo.type)) { fieldInfo.val = valObj[fieldInfo.type as keyof typeof valObj]; } } @@ -397,18 +412,22 @@ function setDefaultVal(fieldInfo: Description) { function setEditVal(eData: obj, item: Description) { if (item.type == typeStr.map) { - item.itemTypeFields?.forEach((ii) => { - setEditVal(eData[item.fieldName], ii); - }); + eData[item.fieldName] && + item.itemTypeFields?.forEach((ii) => { + setEditVal(eData[item.fieldName], ii); + }); } else if (item.type == typeStr.array) { item.val = []; - eData[item.fieldName].forEach((ii: obj) => { - const fs: Description[] = JSON.parse(JSON.stringify(item.itemTypeFields)); - fs.forEach((it: Description) => { - setEditVal(ii, it); + eData[item.fieldName] && + eData[item.fieldName].forEach((ii: obj) => { + const fs: Description[] = JSON.parse( + JSON.stringify(item.itemTypeFields) + ); + fs.forEach((it: Description) => { + setEditVal(ii, it); + }); + item.val.push(fs); }); - item.val.push(fs); - }); } else { let v = valObj[item.type as keyof typeof valObj]; item.val = eData[item.fieldName] || v; diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 5609f83..fcbea4e 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -43,6 +43,7 @@ export namespace graphicData { sectionCodePointList?: SectionCodePoint[]; screenDoorConfig?: ScreenDoorConfig; beacons?: Beacon[]; + generateAxleCountingConfig?: GenerateAxleCountingConfig; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 33, 34, 35, 37], this.#one_of_decls); @@ -140,6 +141,9 @@ export namespace graphicData { if ("beacons" in data && data.beacons != undefined) { this.beacons = data.beacons; } + if ("generateAxleCountingConfig" in data && data.generateAxleCountingConfig != undefined) { + this.generateAxleCountingConfig = data.generateAxleCountingConfig; + } } } get canvas() { @@ -337,6 +341,15 @@ export namespace graphicData { set beacons(value: Beacon[]) { pb_1.Message.setRepeatedWrapperField(this, 37, value); } + get generateAxleCountingConfig() { + return pb_1.Message.getWrapperField(this, GenerateAxleCountingConfig, 38) as GenerateAxleCountingConfig; + } + set generateAxleCountingConfig(value: GenerateAxleCountingConfig) { + pb_1.Message.setWrapperField(this, 38, value); + } + get has_generateAxleCountingConfig() { + return pb_1.Message.getField(this, 38) != null; + } static fromObject(data: { canvas?: ReturnType; Platforms?: ReturnType[]; @@ -369,6 +382,7 @@ export namespace graphicData { sectionCodePointList?: ReturnType[]; screenDoorConfig?: ReturnType; beacons?: ReturnType[]; + generateAxleCountingConfig?: ReturnType; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -464,6 +478,9 @@ export namespace graphicData { if (data.beacons != null) { message.beacons = data.beacons.map(item => Beacon.fromObject(item)); } + if (data.generateAxleCountingConfig != null) { + message.generateAxleCountingConfig = GenerateAxleCountingConfig.fromObject(data.generateAxleCountingConfig); + } return message; } toObject() { @@ -499,6 +516,7 @@ export namespace graphicData { sectionCodePointList?: ReturnType[]; screenDoorConfig?: ReturnType; beacons?: ReturnType[]; + generateAxleCountingConfig?: ReturnType; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -593,6 +611,9 @@ export namespace graphicData { if (this.beacons != null) { data.beacons = this.beacons.map((item: Beacon) => item.toObject()); } + if (this.generateAxleCountingConfig != null) { + data.generateAxleCountingConfig = this.generateAxleCountingConfig.toObject(); + } return data; } serialize(): Uint8Array; @@ -661,6 +682,8 @@ export namespace graphicData { writer.writeMessage(36, this.screenDoorConfig, () => this.screenDoorConfig.serialize(writer)); if (this.beacons.length) writer.writeRepeatedMessage(37, this.beacons, (item: Beacon) => item.serialize(writer)); + if (this.has_generateAxleCountingConfig) + writer.writeMessage(38, this.generateAxleCountingConfig, () => this.generateAxleCountingConfig.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -763,6 +786,9 @@ export namespace graphicData { case 37: reader.readMessage(message.beacons, () => pb_1.Message.addToRepeatedWrapperField(message, 37, Beacon.deserialize(reader), Beacon)); break; + case 38: + reader.readMessage(message.generateAxleCountingConfig, () => message.generateAxleCountingConfig = GenerateAxleCountingConfig.deserialize(reader)); + break; default: reader.skipField(); } } @@ -2406,6 +2432,96 @@ export namespace graphicData { SectionBoundary = 1 } } + export class GenerateAxleCountingConfig extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + bbConnect?: string[]; + noGenerateGroup?: string[]; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("bbConnect" in data && data.bbConnect != undefined) { + this.bbConnect = data.bbConnect; + } + if ("noGenerateGroup" in data && data.noGenerateGroup != undefined) { + this.noGenerateGroup = data.noGenerateGroup; + } + } + } + get bbConnect() { + return pb_1.Message.getFieldWithDefault(this, 1, []) as string[]; + } + set bbConnect(value: string[]) { + pb_1.Message.setField(this, 1, value); + } + get noGenerateGroup() { + return pb_1.Message.getFieldWithDefault(this, 2, []) as string[]; + } + set noGenerateGroup(value: string[]) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + bbConnect?: string[]; + noGenerateGroup?: string[]; + }): GenerateAxleCountingConfig { + const message = new GenerateAxleCountingConfig({}); + if (data.bbConnect != null) { + message.bbConnect = data.bbConnect; + } + if (data.noGenerateGroup != null) { + message.noGenerateGroup = data.noGenerateGroup; + } + return message; + } + toObject() { + const data: { + bbConnect?: string[]; + noGenerateGroup?: string[]; + } = {}; + if (this.bbConnect != null) { + data.bbConnect = this.bbConnect; + } + if (this.noGenerateGroup != null) { + data.noGenerateGroup = this.noGenerateGroup; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.bbConnect.length) + writer.writeRepeatedString(1, this.bbConnect); + if (this.noGenerateGroup.length) + writer.writeRepeatedString(2, this.noGenerateGroup); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GenerateAxleCountingConfig { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GenerateAxleCountingConfig(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + pb_1.Message.addToRepeatedField(message, 1, reader.readString()); + break; + case 2: + pb_1.Message.addToRepeatedField(message, 2, reader.readString()); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): GenerateAxleCountingConfig { + return GenerateAxleCountingConfig.deserialize(bytes); + } + } export class Turnout extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | {