区段状态

This commit is contained in:
Yuan 2023-11-01 13:59:02 +08:00
parent f991d849fc
commit 9bb34e73b4
6 changed files with 375 additions and 379 deletions

@ -1 +1 @@
Subproject commit df9ed054c0bb76f7de1f188ef7fb8c31a6513509 Subproject commit 2a14cd39d1e50848eff33df9cb163a453cde0668

View File

@ -19,8 +19,15 @@
</q-btn-dropdown> </q-btn-dropdown>
</q-card-section> </q-card-section>
<q-separator inset /> <q-separator inset />
<q-card-section>
<q-form> <q-form>
<q-input outlined readonly v-model="sectionState.id" label="id" hint="" /> <q-input
outlined
readonly
v-model="sectionState.id"
label="id"
hint=""
/>
<q-input <q-input
outlined outlined
readonly readonly
@ -35,6 +42,20 @@
label="名称" label="名称"
/> />
</q-form> </q-form>
<q-list dense bordered padding class="rounded-borders q-my-sm">
<q-item>
<q-item-section>
<q-checkbox
dense
v-model="sectionState.axleFault"
outlined
label="是否故障占用"
:disable="true"
/>
</q-item-section>
</q-item>
</q-list>
</q-card-section>
<q-card-actions align="center"> <q-card-actions align="center">
<q-btn label="修改" type="submit" color="primary" @click="submitState" /> <q-btn label="修改" type="submit" color="primary" @click="submitState" />
<q-btn <q-btn
@ -51,15 +72,16 @@
<script setup lang="ts"> <script setup lang="ts">
import { useLineStore } from 'src/stores/line-store'; import { useLineStore } from 'src/stores/line-store';
import { ref, watch, onMounted } from 'vue'; 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 { request } from 'src/protos/request';
import { setAxleSectionState } from 'src/api/Simulation'; import { setAxleSectionState } from 'src/api/Simulation';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
import { SectionStates } from 'src/drawApp/graphics/SectionInteraction';
const $q = useQuasar(); const $q = useQuasar();
const lineStore = useLineStore(); const lineStore = useLineStore();
const sectionState = ref({ id: '', index: 0, code: '' }); const sectionState = ref({ id: '', index: 0, code: '', axleFault: false });
watch( watch(
() => lineStore.selectedGraphics, () => lineStore.selectedGraphics,
@ -71,6 +93,7 @@ watch(
id: '', id: '',
index: 0, index: 0,
code: '', code: '',
axleFault: false,
}; };
} }
} }
@ -84,6 +107,7 @@ function setSectionState(section: Section) {
id: section.datas.id, id: section.datas.id,
index: section.datas.index, index: section.datas.index,
code: section.datas.code, code: section.datas.code,
axleFault: section.states.axleFault ?? false,
}; };
} }
function submitState() { 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,
};
}
}
}
);
</script> </script>

View File

@ -138,18 +138,18 @@ export class SectionStates extends GraphicStateBase implements ISectionState {
set id(id: string) { set id(id: string) {
this.states.id = id; this.states.id = id;
} }
get type(): state.SectionType {
return this.states.type;
}
set type(v: state.SectionType) {
this.states.type = v;
}
get occupied(): boolean { get occupied(): boolean {
return this.states.occupied; return this.states.occupied;
} }
set occupied(occupied: boolean) { set occupied(occupied: boolean) {
this.states.occupied = occupied; this.states.occupied = occupied;
} }
get axleFault(): boolean {
return this.states.axleFault;
}
set axleFault(axleFault: boolean) {
this.states.axleFault = axleFault;
}
get states(): state.SectionState { get states(): state.SectionState {
return this.getState<state.SectionState>(); return this.getState<state.SectionState>();
} }

View File

@ -67,6 +67,7 @@ export interface ISectionState extends GraphicState {
id: string; id: string;
type?: state.SectionType; type?: state.SectionType;
occupied?: boolean; occupied?: boolean;
axleFault?: boolean;
} }
export const SectionConsts = { export const SectionConsts = {

View File

@ -105,8 +105,8 @@ export namespace state {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | { constructor(data?: any[] | {
id?: string; id?: string;
type?: SectionType;
occupied?: boolean; occupied?: boolean;
axleFault?: boolean;
}) { }) {
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);
@ -114,12 +114,12 @@ export namespace state {
if ("id" in data && data.id != undefined) { if ("id" in data && data.id != undefined) {
this.id = data.id; this.id = data.id;
} }
if ("type" in data && data.type != undefined) {
this.type = data.type;
}
if ("occupied" in data && data.occupied != undefined) { if ("occupied" in data && data.occupied != undefined) {
this.occupied = data.occupied; this.occupied = data.occupied;
} }
if ("axleFault" in data && data.axleFault != undefined) {
this.axleFault = data.axleFault;
}
} }
} }
get id() { get id() {
@ -128,50 +128,50 @@ export namespace state {
set id(value: string) { set id(value: string) {
pb_1.Message.setField(this, 1, value); 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() { get occupied() {
return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean; return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean;
} }
set occupied(value: boolean) { set occupied(value: boolean) {
pb_1.Message.setField(this, 3, value); 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: { static fromObject(data: {
id?: string; id?: string;
type?: SectionType;
occupied?: boolean; occupied?: boolean;
axleFault?: boolean;
}): SectionState { }): SectionState {
const message = new SectionState({}); const message = new SectionState({});
if (data.id != null) { if (data.id != null) {
message.id = data.id; message.id = data.id;
} }
if (data.type != null) {
message.type = data.type;
}
if (data.occupied != null) { if (data.occupied != null) {
message.occupied = data.occupied; message.occupied = data.occupied;
} }
if (data.axleFault != null) {
message.axleFault = data.axleFault;
}
return message; return message;
} }
toObject() { toObject() {
const data: { const data: {
id?: string; id?: string;
type?: SectionType;
occupied?: boolean; occupied?: boolean;
axleFault?: boolean;
} = {}; } = {};
if (this.id != null) { if (this.id != null) {
data.id = this.id; data.id = this.id;
} }
if (this.type != null) {
data.type = this.type;
}
if (this.occupied != null) { if (this.occupied != null) {
data.occupied = this.occupied; data.occupied = this.occupied;
} }
if (this.axleFault != null) {
data.axleFault = this.axleFault;
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
@ -180,10 +180,10 @@ export namespace state {
const writer = w || new pb_1.BinaryWriter(); const writer = w || new pb_1.BinaryWriter();
if (this.id.length) if (this.id.length)
writer.writeString(1, this.id); writer.writeString(1, this.id);
if (this.type != SectionType.Any)
writer.writeEnum(2, this.type);
if (this.occupied != false) if (this.occupied != false)
writer.writeBool(3, this.occupied); writer.writeBool(3, this.occupied);
if (this.axleFault != false)
writer.writeBool(4, this.axleFault);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -196,12 +196,12 @@ export namespace state {
case 1: case 1:
message.id = reader.readString(); message.id = reader.readString();
break; break;
case 2:
message.type = reader.readEnum();
break;
case 3: case 3:
message.occupied = reader.readBool(); message.occupied = reader.readBool();
break; break;
case 4:
message.axleFault = reader.readBool();
break;
default: reader.skipField(); default: reader.skipField();
} }
} }

View File

@ -3,22 +3,14 @@
* compiler version: 4.23.1 * compiler version: 4.23.1
* source: request.proto * source: request.proto
* git: https://github.com/thesayyn/protoc-gen-ts */ * 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 namespace request {
export class Turnout extends pb_1.Message { export class Turnout extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | {}) { constructor(data?: any[] | {}) {
super(); super();
pb_1.Message.initialize( pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
this, if (!Array.isArray(data) && typeof data == "object") { }
Array.isArray(data) ? data : [],
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == 'object') {
}
} }
static fromObject(data: {}): Turnout { static fromObject(data: {}): Turnout {
const message = new Turnout({}); const message = new Turnout({});
@ -32,19 +24,16 @@ export namespace request {
serialize(w: pb_1.BinaryWriter): void; serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void { serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter(); const writer = w || new pb_1.BinaryWriter();
if (!w) return writer.getResultBuffer(); if (!w)
return writer.getResultBuffer();
} }
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Turnout { static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Turnout {
const reader = const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Turnout();
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new Turnout();
while (reader.nextField()) { while (reader.nextField()) {
if (reader.isEndGroup()) break; if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) { switch (reader.getFieldNumber()) {
default: default: reader.skipField();
reader.skipField();
} }
} }
return message; return message;
@ -69,47 +58,36 @@ export namespace request {
CancelJC = 8, CancelJC = 8,
ForceDw = 9, ForceDw = 9,
ForceFw = 10, ForceFw = 10,
CancelForce = 11, CancelForce = 11
} }
} }
export class TurnoutOperationReq extends pb_1.Message { export class TurnoutOperationReq extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor( constructor(data?: any[] | {
data?:
| any[]
| {
simulationId?: string; simulationId?: string;
mapId?: number; mapId?: number;
deviceId?: string; deviceId?: string;
operation?: Turnout.Operation; operation?: Turnout.Operation;
} }) {
) {
super(); super();
pb_1.Message.initialize( pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
this, if (!Array.isArray(data) && typeof data == "object") {
Array.isArray(data) ? data : [], if ("simulationId" in data && data.simulationId != undefined) {
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == 'object') {
if ('simulationId' in data && data.simulationId != undefined) {
this.simulationId = data.simulationId; this.simulationId = data.simulationId;
} }
if ('mapId' in data && data.mapId != undefined) { if ("mapId" in data && data.mapId != undefined) {
this.mapId = data.mapId; this.mapId = data.mapId;
} }
if ('deviceId' in data && data.deviceId != undefined) { if ("deviceId" in data && data.deviceId != undefined) {
this.deviceId = data.deviceId; this.deviceId = data.deviceId;
} }
if ('operation' in data && data.operation != undefined) { if ("operation" in data && data.operation != undefined) {
this.operation = data.operation; this.operation = data.operation;
} }
} }
} }
get simulationId() { get simulationId() {
return pb_1.Message.getFieldWithDefault(this, 1, '') as string; return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
} }
set simulationId(value: string) { set simulationId(value: string) {
pb_1.Message.setField(this, 1, value); pb_1.Message.setField(this, 1, value);
@ -121,17 +99,13 @@ export namespace request {
pb_1.Message.setField(this, 2, value); pb_1.Message.setField(this, 2, value);
} }
get deviceId() { get deviceId() {
return pb_1.Message.getFieldWithDefault(this, 3, '') as string; return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
} }
set deviceId(value: string) { set deviceId(value: string) {
pb_1.Message.setField(this, 3, value); pb_1.Message.setField(this, 3, value);
} }
get operation() { get operation() {
return pb_1.Message.getFieldWithDefault( return pb_1.Message.getFieldWithDefault(this, 4, Turnout.Operation.Undefined) as Turnout.Operation;
this,
4,
Turnout.Operation.Undefined
) as Turnout.Operation;
} }
set operation(value: Turnout.Operation) { set operation(value: Turnout.Operation) {
pb_1.Message.setField(this, 4, value); pb_1.Message.setField(this, 4, value);
@ -182,23 +156,22 @@ export namespace request {
serialize(w: pb_1.BinaryWriter): void; serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void { serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter(); const writer = w || new pb_1.BinaryWriter();
if (this.simulationId.length) writer.writeString(1, this.simulationId); if (this.simulationId.length)
if (this.mapId != 0) writer.writeInt32(2, this.mapId); writer.writeString(1, this.simulationId);
if (this.deviceId.length) writer.writeString(3, this.deviceId); if (this.mapId != 0)
writer.writeInt32(2, this.mapId);
if (this.deviceId.length)
writer.writeString(3, this.deviceId);
if (this.operation != Turnout.Operation.Undefined) if (this.operation != Turnout.Operation.Undefined)
writer.writeEnum(4, this.operation); writer.writeEnum(4, this.operation);
if (!w) return writer.getResultBuffer(); if (!w)
return writer.getResultBuffer();
} }
static deserialize( static deserialize(bytes: Uint8Array | pb_1.BinaryReader): TurnoutOperationReq {
bytes: Uint8Array | pb_1.BinaryReader const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TurnoutOperationReq();
): TurnoutOperationReq {
const reader =
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new TurnoutOperationReq();
while (reader.nextField()) { while (reader.nextField()) {
if (reader.isEndGroup()) break; if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) { switch (reader.getFieldNumber()) {
case 1: case 1:
message.simulationId = reader.readString(); message.simulationId = reader.readString();
@ -212,8 +185,7 @@ export namespace request {
case 4: case 4:
message.operation = reader.readEnum(); message.operation = reader.readEnum();
break; break;
default: default: reader.skipField();
reader.skipField();
} }
} }
return message; return message;
@ -229,16 +201,8 @@ export namespace request {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | {}) { constructor(data?: any[] | {}) {
super(); super();
pb_1.Message.initialize( pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
this, if (!Array.isArray(data) && typeof data == "object") { }
Array.isArray(data) ? data : [],
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == 'object') {
}
} }
static fromObject(data: {}): Signal { static fromObject(data: {}): Signal {
const message = new Signal({}); const message = new Signal({});
@ -252,19 +216,16 @@ export namespace request {
serialize(w: pb_1.BinaryWriter): void; serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void { serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter(); const writer = w || new pb_1.BinaryWriter();
if (!w) return writer.getResultBuffer(); if (!w)
return writer.getResultBuffer();
} }
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Signal { static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Signal {
const reader = const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Signal();
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new Signal();
while (reader.nextField()) { while (reader.nextField()) {
if (reader.isEndGroup()) break; if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) { switch (reader.getFieldNumber()) {
default: default: reader.skipField();
reader.skipField();
} }
} }
return message; return message;
@ -289,23 +250,15 @@ export namespace request {
LightUCancelDs = 8, LightUCancelDs = 8,
LightLCancelDs = 9, LightLCancelDs = 9,
LightACancelDs = 10, LightACancelDs = 10,
LightBCancelDs = 11, LightBCancelDs = 11
} }
} }
export class Section extends pb_1.Message { export class Section extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | {}) { constructor(data?: any[] | {}) {
super(); super();
pb_1.Message.initialize( pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
this, if (!Array.isArray(data) && typeof data == "object") { }
Array.isArray(data) ? data : [],
0,
-1,
[],
this.#one_of_decls
);
if (!Array.isArray(data) && typeof data == 'object') {
}
} }
static fromObject(data: {}): Section { static fromObject(data: {}): Section {
const message = new Section({}); const message = new Section({});
@ -319,19 +272,16 @@ export namespace request {
serialize(w: pb_1.BinaryWriter): void; serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void { serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter(); const writer = w || new pb_1.BinaryWriter();
if (!w) return writer.getResultBuffer(); if (!w)
return writer.getResultBuffer();
} }
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Section { static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Section {
const reader = const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Section();
bytes instanceof pb_1.BinaryReader
? bytes
: new pb_1.BinaryReader(bytes),
message = new Section();
while (reader.nextField()) { while (reader.nextField()) {
if (reader.isEndGroup()) break; if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) { switch (reader.getFieldNumber()) {
default: default: reader.skipField();
reader.skipField();
} }
} }
return message; return message;
@ -350,7 +300,7 @@ export namespace request {
SetPdrst = 2, SetPdrst = 2,
CancelPdrst = 3, CancelPdrst = 3,
SetFaultOcc = 4, SetFaultOcc = 4,
CancelFaultOcc = 5, CancelFaultOcc = 5
} }
} }
} }