区段状态

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-card-section>
<q-separator inset />
<q-card-section>
<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
outlined
readonly
@ -35,6 +42,20 @@
label="名称"
/>
</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-btn label="修改" type="submit" color="primary" @click="submitState" />
<q-btn
@ -51,15 +72,16 @@
<script setup lang="ts">
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,
};
}
}
}
);
</script>

View File

@ -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<state.SectionState>();
}

View File

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

View File

@ -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();
}
}

View File

@ -3,22 +3,14 @@
* 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') {
}
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({});
@ -32,19 +24,16 @@ export namespace request {
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();
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();
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Turnout();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default:
reader.skipField();
default: reader.skipField();
}
}
return message;
@ -69,47 +58,36 @@ export namespace request {
CancelJC = 8,
ForceDw = 9,
ForceFw = 10,
CancelForce = 11,
CancelForce = 11
}
}
export class TurnoutOperationReq extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(
data?:
| any[]
| {
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) {
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) {
if ("mapId" in data && data.mapId != undefined) {
this.mapId = data.mapId;
}
if ('deviceId' in data && data.deviceId != undefined) {
if ("deviceId" in data && data.deviceId != undefined) {
this.deviceId = data.deviceId;
}
if ('operation' in data && data.operation != undefined) {
if ("operation" in data && data.operation != undefined) {
this.operation = data.operation;
}
}
}
get simulationId() {
return pb_1.Message.getFieldWithDefault(this, 1, '') as string;
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set simulationId(value: string) {
pb_1.Message.setField(this, 1, value);
@ -121,17 +99,13 @@ export namespace request {
pb_1.Message.setField(this, 2, value);
}
get deviceId() {
return pb_1.Message.getFieldWithDefault(this, 3, '') as string;
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;
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);
@ -182,23 +156,22 @@ export namespace request {
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.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();
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();
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;
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.simulationId = reader.readString();
@ -212,8 +185,7 @@ export namespace request {
case 4:
message.operation = reader.readEnum();
break;
default:
reader.skipField();
default: reader.skipField();
}
}
return message;
@ -229,16 +201,8 @@ export namespace request {
#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') {
}
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({});
@ -252,19 +216,16 @@ export namespace request {
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();
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();
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Signal();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default:
reader.skipField();
default: reader.skipField();
}
}
return message;
@ -289,23 +250,15 @@ export namespace request {
LightUCancelDs = 8,
LightLCancelDs = 9,
LightACancelDs = 10,
LightBCancelDs = 11,
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') {
}
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({});
@ -319,19 +272,16 @@ export namespace request {
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();
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();
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Section();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default:
reader.skipField();
default: reader.skipField();
}
}
return message;
@ -350,7 +300,7 @@ export namespace request {
SetPdrst = 2,
CancelPdrst = 3,
SetFaultOcc = 4,
CancelFaultOcc = 5,
CancelFaultOcc = 5
}
}
}