diff --git a/bj-rtss-message b/bj-rtss-message index df9ed05..2a14cd3 160000 --- a/bj-rtss-message +++ b/bj-rtss-message @@ -1 +1 @@ -Subproject commit df9ed054c0bb76f7de1f188ef7fb8c31a6513509 +Subproject commit 2a14cd39d1e50848eff33df9cb163a453cde0668 diff --git a/src/components/line-app/states/SectionState.vue b/src/components/line-app/states/SectionState.vue index afba07b..aa04a2e 100644 --- a/src/components/line-app/states/SectionState.vue +++ b/src/components/line-app/states/SectionState.vue @@ -19,22 +19,43 @@ - - - - - + + + + + + + + + + + + + + import { useLineStore } from 'src/stores/line-store'; import { ref, watch, onMounted } from 'vue'; -import { Section } from 'src/graphics/section/Section'; +import { Section, type ISectionState } from 'src/graphics/section/Section'; import { request } from 'src/protos/request'; import { setAxleSectionState } from 'src/api/Simulation'; import { useQuasar } from 'quasar'; import { ApiError } from 'src/boot/axios'; +import { SectionStates } from 'src/drawApp/graphics/SectionInteraction'; const $q = useQuasar(); const lineStore = useLineStore(); -const sectionState = ref({ id: '', index: 0, code: '' }); +const sectionState = ref({ id: '', index: 0, code: '', axleFault: false }); watch( () => lineStore.selectedGraphics, @@ -71,6 +93,7 @@ watch( id: '', index: 0, code: '', + axleFault: false, }; } } @@ -84,6 +107,7 @@ function setSectionState(section: Section) { id: section.datas.id, index: section.datas.index, code: section.datas.code, + axleFault: section.states.axleFault ?? false, }; } function submitState() { @@ -148,4 +172,25 @@ function toDo(item: { label: string; value: number }) { }); }); } +watch( + () => lineStore.socketStates, + (val) => { + if (val && sectionState.value.id) { + const find = val.find((item): item is SectionStates => { + return ( + item.graphicType == Section.Type && + (item as ISectionState).id == sectionState.value.id + ); + }); + if (find) { + sectionState.value = { + index: sectionState.value.index, + id: find.id, + code: find.code, + axleFault: find.axleFault, + }; + } + } + } +); diff --git a/src/drawApp/graphics/SectionInteraction.ts b/src/drawApp/graphics/SectionInteraction.ts index ea4b47b..80d6f2c 100644 --- a/src/drawApp/graphics/SectionInteraction.ts +++ b/src/drawApp/graphics/SectionInteraction.ts @@ -138,18 +138,18 @@ export class SectionStates extends GraphicStateBase implements ISectionState { set id(id: string) { this.states.id = id; } - get type(): state.SectionType { - return this.states.type; - } - set type(v: state.SectionType) { - this.states.type = v; - } get occupied(): boolean { return this.states.occupied; } set occupied(occupied: boolean) { this.states.occupied = occupied; } + get axleFault(): boolean { + return this.states.axleFault; + } + set axleFault(axleFault: boolean) { + this.states.axleFault = axleFault; + } get states(): state.SectionState { return this.getState(); } diff --git a/src/graphics/section/Section.ts b/src/graphics/section/Section.ts index abd2fe5..19a081e 100644 --- a/src/graphics/section/Section.ts +++ b/src/graphics/section/Section.ts @@ -67,6 +67,7 @@ export interface ISectionState extends GraphicState { id: string; type?: state.SectionType; occupied?: boolean; + axleFault?: boolean; } export const SectionConsts = { diff --git a/src/protos/device_state.ts b/src/protos/device_state.ts index 4287152..dc1a41c 100644 --- a/src/protos/device_state.ts +++ b/src/protos/device_state.ts @@ -105,8 +105,8 @@ export namespace state { #one_of_decls: number[][] = []; constructor(data?: any[] | { id?: string; - type?: SectionType; occupied?: boolean; + axleFault?: boolean; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -114,12 +114,12 @@ export namespace state { if ("id" in data && data.id != undefined) { this.id = data.id; } - if ("type" in data && data.type != undefined) { - this.type = data.type; - } if ("occupied" in data && data.occupied != undefined) { this.occupied = data.occupied; } + if ("axleFault" in data && data.axleFault != undefined) { + this.axleFault = data.axleFault; + } } } get id() { @@ -128,50 +128,50 @@ export namespace state { set id(value: string) { pb_1.Message.setField(this, 1, value); } - get type() { - return pb_1.Message.getFieldWithDefault(this, 2, SectionType.Any) as SectionType; - } - set type(value: SectionType) { - pb_1.Message.setField(this, 2, value); - } get occupied() { return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean; } set occupied(value: boolean) { pb_1.Message.setField(this, 3, value); } + get axleFault() { + return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean; + } + set axleFault(value: boolean) { + pb_1.Message.setField(this, 4, value); + } static fromObject(data: { id?: string; - type?: SectionType; occupied?: boolean; + axleFault?: boolean; }): SectionState { const message = new SectionState({}); if (data.id != null) { message.id = data.id; } - if (data.type != null) { - message.type = data.type; - } if (data.occupied != null) { message.occupied = data.occupied; } + if (data.axleFault != null) { + message.axleFault = data.axleFault; + } return message; } toObject() { const data: { id?: string; - type?: SectionType; occupied?: boolean; + axleFault?: boolean; } = {}; if (this.id != null) { data.id = this.id; } - if (this.type != null) { - data.type = this.type; - } if (this.occupied != null) { data.occupied = this.occupied; } + if (this.axleFault != null) { + data.axleFault = this.axleFault; + } return data; } serialize(): Uint8Array; @@ -180,10 +180,10 @@ export namespace state { const writer = w || new pb_1.BinaryWriter(); if (this.id.length) writer.writeString(1, this.id); - if (this.type != SectionType.Any) - writer.writeEnum(2, this.type); if (this.occupied != false) writer.writeBool(3, this.occupied); + if (this.axleFault != false) + writer.writeBool(4, this.axleFault); if (!w) return writer.getResultBuffer(); } @@ -196,12 +196,12 @@ export namespace state { case 1: message.id = reader.readString(); break; - case 2: - message.type = reader.readEnum(); - break; case 3: message.occupied = reader.readBool(); break; + case 4: + message.axleFault = reader.readBool(); + break; default: reader.skipField(); } } diff --git a/src/protos/request.ts b/src/protos/request.ts index 2becd84..81806e3 100644 --- a/src/protos/request.ts +++ b/src/protos/request.ts @@ -3,354 +3,304 @@ * compiler version: 4.23.1 * source: request.proto * git: https://github.com/thesayyn/protoc-gen-ts */ -import * as pb_1 from 'google-protobuf'; +import * as pb_1 from "google-protobuf"; export namespace request { - export class Turnout extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | {}) { - super(); - pb_1.Message.initialize( - this, - Array.isArray(data) ? data : [], - 0, - -1, - [], - this.#one_of_decls - ); - if (!Array.isArray(data) && typeof data == 'object') { - } - } - static fromObject(data: {}): Turnout { - const message = new Turnout({}); - return message; - } - toObject() { - const data: {} = {}; - 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 (!w) return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Turnout { - const reader = - bytes instanceof pb_1.BinaryReader - ? bytes - : new pb_1.BinaryReader(bytes), - message = new Turnout(); - while (reader.nextField()) { - if (reader.isEndGroup()) break; - switch (reader.getFieldNumber()) { - default: - reader.skipField(); + export class Turnout extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | {}) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { } + } + static fromObject(data: {}): Turnout { + const message = new Turnout({}); + return message; + } + toObject() { + const data: {} = {}; + 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 (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Turnout { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Turnout(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Turnout { + return Turnout.deserialize(bytes); } - } - return message; } - serializeBinary(): Uint8Array { - return this.serialize(); + export namespace Turnout { + export enum Operation { + Undefined = 0, + DC = 1, + CancelDC = 2, + FC = 3, + CancelFC = 4, + SetSB = 5, + CancelSB = 6, + SetJC = 7, + CancelJC = 8, + ForceDw = 9, + ForceFw = 10, + CancelForce = 11 + } } - static deserializeBinary(bytes: Uint8Array): Turnout { - return Turnout.deserialize(bytes); - } - } - export namespace Turnout { - export enum Operation { - Undefined = 0, - DC = 1, - CancelDC = 2, - FC = 3, - CancelFC = 4, - SetSB = 5, - CancelSB = 6, - SetJC = 7, - CancelJC = 8, - ForceDw = 9, - ForceFw = 10, - CancelForce = 11, - } - } - export class TurnoutOperationReq extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor( - data?: - | any[] - | { + export class TurnoutOperationReq extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { simulationId?: string; mapId?: number; deviceId?: string; operation?: Turnout.Operation; - } - ) { - super(); - pb_1.Message.initialize( - this, - Array.isArray(data) ? data : [], - 0, - -1, - [], - this.#one_of_decls - ); - if (!Array.isArray(data) && typeof data == 'object') { - if ('simulationId' in data && data.simulationId != undefined) { - this.simulationId = data.simulationId; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("simulationId" in data && data.simulationId != undefined) { + this.simulationId = data.simulationId; + } + if ("mapId" in data && data.mapId != undefined) { + this.mapId = data.mapId; + } + if ("deviceId" in data && data.deviceId != undefined) { + this.deviceId = data.deviceId; + } + if ("operation" in data && data.operation != undefined) { + this.operation = data.operation; + } + } } - if ('mapId' in data && data.mapId != undefined) { - this.mapId = data.mapId; + get simulationId() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; } - if ('deviceId' in data && data.deviceId != undefined) { - this.deviceId = data.deviceId; + set simulationId(value: string) { + pb_1.Message.setField(this, 1, value); } - if ('operation' in data && data.operation != undefined) { - this.operation = data.operation; + get mapId() { + return pb_1.Message.getFieldWithDefault(this, 2, 0) as number; } - } - } - get simulationId() { - return pb_1.Message.getFieldWithDefault(this, 1, '') as string; - } - set simulationId(value: string) { - pb_1.Message.setField(this, 1, value); - } - get mapId() { - return pb_1.Message.getFieldWithDefault(this, 2, 0) as number; - } - set mapId(value: number) { - pb_1.Message.setField(this, 2, value); - } - get deviceId() { - return pb_1.Message.getFieldWithDefault(this, 3, '') as string; - } - set deviceId(value: string) { - pb_1.Message.setField(this, 3, value); - } - get operation() { - return pb_1.Message.getFieldWithDefault( - this, - 4, - Turnout.Operation.Undefined - ) as Turnout.Operation; - } - set operation(value: Turnout.Operation) { - pb_1.Message.setField(this, 4, value); - } - static fromObject(data: { - simulationId?: string; - mapId?: number; - deviceId?: string; - operation?: Turnout.Operation; - }): TurnoutOperationReq { - const message = new TurnoutOperationReq({}); - if (data.simulationId != null) { - message.simulationId = data.simulationId; - } - if (data.mapId != null) { - message.mapId = data.mapId; - } - if (data.deviceId != null) { - message.deviceId = data.deviceId; - } - if (data.operation != null) { - message.operation = data.operation; - } - return message; - } - toObject() { - const data: { - simulationId?: string; - mapId?: number; - deviceId?: string; - operation?: Turnout.Operation; - } = {}; - if (this.simulationId != null) { - data.simulationId = this.simulationId; - } - if (this.mapId != null) { - data.mapId = this.mapId; - } - if (this.deviceId != null) { - data.deviceId = this.deviceId; - } - if (this.operation != null) { - data.operation = this.operation; - } - 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.simulationId.length) writer.writeString(1, this.simulationId); - if (this.mapId != 0) writer.writeInt32(2, this.mapId); - if (this.deviceId.length) writer.writeString(3, this.deviceId); - if (this.operation != Turnout.Operation.Undefined) - writer.writeEnum(4, this.operation); - if (!w) return writer.getResultBuffer(); - } - static deserialize( - bytes: Uint8Array | pb_1.BinaryReader - ): TurnoutOperationReq { - const reader = - bytes instanceof pb_1.BinaryReader - ? bytes - : new pb_1.BinaryReader(bytes), - message = new TurnoutOperationReq(); - while (reader.nextField()) { - if (reader.isEndGroup()) break; - switch (reader.getFieldNumber()) { - case 1: - message.simulationId = reader.readString(); - break; - case 2: - message.mapId = reader.readInt32(); - break; - case 3: - message.deviceId = reader.readString(); - break; - case 4: - message.operation = reader.readEnum(); - break; - default: - reader.skipField(); + set mapId(value: number) { + pb_1.Message.setField(this, 2, value); } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): TurnoutOperationReq { - return TurnoutOperationReq.deserialize(bytes); - } - } - export class Signal extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | {}) { - super(); - pb_1.Message.initialize( - this, - Array.isArray(data) ? data : [], - 0, - -1, - [], - this.#one_of_decls - ); - if (!Array.isArray(data) && typeof data == 'object') { - } - } - static fromObject(data: {}): Signal { - const message = new Signal({}); - return message; - } - toObject() { - const data: {} = {}; - 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 (!w) return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Signal { - const reader = - bytes instanceof pb_1.BinaryReader - ? bytes - : new pb_1.BinaryReader(bytes), - message = new Signal(); - while (reader.nextField()) { - if (reader.isEndGroup()) break; - switch (reader.getFieldNumber()) { - default: - reader.skipField(); + get deviceId() { + return pb_1.Message.getFieldWithDefault(this, 3, "") as string; } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): Signal { - return Signal.deserialize(bytes); - } - } - export namespace Signal { - export enum Operation { - Undefined = 0, - Display = 1, - LightHFaultDs = 2, - LightUFaultDs = 3, - LightLFaultDs = 4, - LightAFaultDs = 5, - LightBFaultDs = 6, - LightHCancelDs = 7, - LightUCancelDs = 8, - LightLCancelDs = 9, - LightACancelDs = 10, - LightBCancelDs = 11, - } - } - export class Section extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | {}) { - super(); - pb_1.Message.initialize( - this, - Array.isArray(data) ? data : [], - 0, - -1, - [], - this.#one_of_decls - ); - if (!Array.isArray(data) && typeof data == 'object') { - } - } - static fromObject(data: {}): Section { - const message = new Section({}); - return message; - } - toObject() { - const data: {} = {}; - 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 (!w) return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Section { - const reader = - bytes instanceof pb_1.BinaryReader - ? bytes - : new pb_1.BinaryReader(bytes), - message = new Section(); - while (reader.nextField()) { - if (reader.isEndGroup()) break; - switch (reader.getFieldNumber()) { - default: - reader.skipField(); + set deviceId(value: string) { + pb_1.Message.setField(this, 3, value); + } + get operation() { + return pb_1.Message.getFieldWithDefault(this, 4, Turnout.Operation.Undefined) as Turnout.Operation; + } + set operation(value: Turnout.Operation) { + pb_1.Message.setField(this, 4, value); + } + static fromObject(data: { + simulationId?: string; + mapId?: number; + deviceId?: string; + operation?: Turnout.Operation; + }): TurnoutOperationReq { + const message = new TurnoutOperationReq({}); + if (data.simulationId != null) { + message.simulationId = data.simulationId; + } + if (data.mapId != null) { + message.mapId = data.mapId; + } + if (data.deviceId != null) { + message.deviceId = data.deviceId; + } + if (data.operation != null) { + message.operation = data.operation; + } + return message; + } + toObject() { + const data: { + simulationId?: string; + mapId?: number; + deviceId?: string; + operation?: Turnout.Operation; + } = {}; + if (this.simulationId != null) { + data.simulationId = this.simulationId; + } + if (this.mapId != null) { + data.mapId = this.mapId; + } + if (this.deviceId != null) { + data.deviceId = this.deviceId; + } + if (this.operation != null) { + data.operation = this.operation; + } + 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.simulationId.length) + writer.writeString(1, this.simulationId); + if (this.mapId != 0) + writer.writeInt32(2, this.mapId); + if (this.deviceId.length) + writer.writeString(3, this.deviceId); + if (this.operation != Turnout.Operation.Undefined) + writer.writeEnum(4, this.operation); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): TurnoutOperationReq { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TurnoutOperationReq(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.simulationId = reader.readString(); + break; + case 2: + message.mapId = reader.readInt32(); + break; + case 3: + message.deviceId = reader.readString(); + break; + case 4: + message.operation = reader.readEnum(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): TurnoutOperationReq { + return TurnoutOperationReq.deserialize(bytes); } - } - return message; } - serializeBinary(): Uint8Array { - return this.serialize(); + export class Signal extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | {}) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { } + } + static fromObject(data: {}): Signal { + const message = new Signal({}); + return message; + } + toObject() { + const data: {} = {}; + 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 (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Signal { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Signal(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Signal { + return Signal.deserialize(bytes); + } } - static deserializeBinary(bytes: Uint8Array): Section { - return Section.deserialize(bytes); + export namespace Signal { + export enum Operation { + Undefined = 0, + Display = 1, + LightHFaultDs = 2, + LightUFaultDs = 3, + LightLFaultDs = 4, + LightAFaultDs = 5, + LightBFaultDs = 6, + LightHCancelDs = 7, + LightUCancelDs = 8, + LightLCancelDs = 9, + LightACancelDs = 10, + LightBCancelDs = 11 + } } - } - export namespace Section { - export enum Operation { - SetDrst = 0, - CancelDrst = 1, - SetPdrst = 2, - CancelPdrst = 3, - SetFaultOcc = 4, - CancelFaultOcc = 5, + export class Section extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | {}) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { } + } + static fromObject(data: {}): Section { + const message = new Section({}); + return message; + } + toObject() { + const data: {} = {}; + 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 (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Section { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Section(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Section { + return Section.deserialize(bytes); + } + } + export namespace Section { + export enum Operation { + SetDrst = 0, + CancelDrst = 1, + SetPdrst = 2, + CancelPdrst = 3, + SetFaultOcc = 4, + CancelFaultOcc = 5 + } } - } }