道岔操作

This commit is contained in:
joylink_zhaoerwei 2024-01-18 13:39:31 +08:00
parent 9cc9c96671
commit c762a5df55
6 changed files with 565 additions and 93 deletions

View File

@ -111,6 +111,7 @@ export interface SetSwitchParams {
mapId: number; mapId: number;
deviceId: number; deviceId: number;
operation: number; operation: number;
param: { forcePosition: number };
} }
export async function setSwitchPosition(data: SetSwitchParams) { export async function setSwitchPosition(data: SetSwitchParams) {

View File

@ -0,0 +1,95 @@
<!-- eslint-disable vue/no-mutating-props -->
<template>
<q-dialog ref="dialogRef">
<q-card style="width: 300px">
<q-card-section>
<q-form ref="myForm" @submit="onCreate" class="q-gutter-md">
<div class="text-h6">道岔设置参数</div>
<q-input dense outlined readonly label="道岔" v-model="props.code" />
<q-select
outlined
v-model="turnoutOperation"
:options="turnoutOperationOption"
:map-options="true"
:emit-value="true"
label="道岔操作"
:rules="[(val) => val >= 0 || '请选择道岔操作类型!']"
/>
<q-select
outlined
v-model="turnoutForce"
:options="turnoutForceOption"
:map-options="true"
:emit-value="true"
label="道岔强制"
:rules="[(val) => val >= 0 || '请选择道岔强制类型!']"
/>
<q-card-actions align="right" class="text-primary">
<q-btn flat label="取消" @click="onDialogCancel" v-close-popup />
<q-btn flat label="确认" type="submit" />
</q-card-actions>
</q-form>
</q-card-section>
</q-card>
</q-dialog>
</template>
<script setup lang="ts">
import { QForm, useDialogPluginComponent } from 'quasar';
import { request } from 'src/protos/request';
import { ref } from 'vue';
const props = defineProps({
code: {
type: String,
required: true,
},
});
const turnoutOperation = ref<request.Points.Operation>();
const turnoutOperationOption = [
{
label: '未定义',
value: request.Points.Operation.Undefined,
},
{
label: '设置参数',
value: request.Points.Operation.SetParams,
},
];
const turnoutForce = ref<request.Points.Force>();
const turnoutForceOption = [
{
label: '无强制',
value: request.Points.Force.FP_NONE,
},
{
label: '定位',
value: request.Points.Force.FP_DW,
},
{
label: '反位',
value: request.Points.Force.FP_FW,
},
{
label: '失表',
value: request.Points.Force.FP_SB,
},
];
defineEmits([...useDialogPluginComponent.emits]);
const { dialogRef, onDialogOK, onDialogCancel } = useDialogPluginComponent();
const myForm = ref<QForm | null>(null);
function onCreate() {
myForm.value?.validate().then(async (res) => {
if (res) {
onDialogOK({
operation: turnoutOperation.value,
forcePosition: turnoutForce.value,
});
}
});
}
</script>
<style scoped></style>

View File

@ -9,7 +9,7 @@
:key="index" :key="index"
clickable clickable
v-close-popup v-close-popup
@click="toDo(item)" @click="doTurnoutOperation(item)"
> >
<q-item-section> <q-item-section>
<q-item-label>{{ item.label }}</q-item-label> <q-item-label>{{ item.label }}</q-item-label>
@ -208,13 +208,12 @@ import { Turnout } from 'src/graphics/turnout/Turnout';
import { useLineStore } from 'src/stores/line-store'; import { useLineStore } from 'src/stores/line-store';
import { ref, watch, onMounted, onUnmounted } from 'vue'; import { ref, watch, onMounted, onUnmounted } from 'vue';
import { SetSwitchParams, setSwitchPosition } from 'src/api/Simulation'; import { SetSwitchParams, setSwitchPosition } from 'src/api/Simulation';
import { useQuasar } from 'quasar'; import { Dialog } from 'quasar';
import { ApiError } from 'src/boot/axios';
import { request } from 'src/protos/request';
import { TurnoutStates } from 'src/drawApp/graphics/TurnoutInteraction'; import { TurnoutStates } from 'src/drawApp/graphics/TurnoutInteraction';
import TurnoutOperation from 'src/components/draw-app/dialogs/TurnoutOperation.vue';
import { JlGraphic } from 'jl-graphic'; import { JlGraphic } from 'jl-graphic';
import { errorNotify } from 'src/utils/CommonNotify';
const $q = useQuasar();
const lineStore = useLineStore(); const lineStore = useLineStore();
const turnoutState = ref<TurnoutStates>(new TurnoutStates()); const turnoutState = ref<TurnoutStates>(new TurnoutStates());
const name = ref(''); const name = ref('');
@ -254,34 +253,32 @@ onUnmounted(() => {
} }
}); });
const options = [ const options = [{ label: '设置参数' }];
{ label: '定操', value: request.Turnout.Operation.DC }, function doTurnoutOperation(item: { label: string }) {
{ label: '取消定操', value: request.Turnout.Operation.CancelDC },
{ label: '反操', value: request.Turnout.Operation.FC },
{ label: '取消反操', value: request.Turnout.Operation.CancelFC },
{ label: '设置失表故障', value: request.Turnout.Operation.SetSB },
{ label: '取消失表故障', value: request.Turnout.Operation.CancelSB },
{ label: '设置挤岔故障', value: request.Turnout.Operation.SetJC },
{ label: '取消挤岔故障', value: request.Turnout.Operation.CancelJC },
{ label: '强制定位', value: request.Turnout.Operation.ForceDw },
{ label: '强制反位', value: request.Turnout.Operation.ForceFw },
{ label: '取消强制', value: request.Turnout.Operation.CancelForce },
];
function toDo(item: { label: string; value: number }) {
if (!lineStore.simulationId) return; if (!lineStore.simulationId) return;
if (item.label == '设置参数') {
Dialog.create({
title: '道岔设置参数',
message: '',
component: TurnoutOperation,
componentProps: {
code: name.value,
},
cancel: true,
persistent: true,
}).onOk((data) => {
const obj: SetSwitchParams = { const obj: SetSwitchParams = {
simulationId: lineStore?.simulationId || '', simulationId: lineStore?.simulationId || '',
mapId: lineStore.mapId as number, mapId: lineStore.mapId as number,
deviceId: turnoutState.value.id, deviceId: turnoutState.value.id,
operation: item.value, operation: data.operation,
param: { forcePosition: data.forcePosition },
}; };
setSwitchPosition(obj).catch((err) => { setSwitchPosition(obj).catch((e) =>
const error = err as ApiError; errorNotify('道岔操作失败:' + e.title, e)
$q.notify({ );
type: 'negative',
message: error.title,
});
}); });
}
} }
function subscribeState(g: JlGraphic) { function subscribeState(g: JlGraphic) {

View File

@ -22,13 +22,13 @@ import {
TurnoutSectionHitArea, TurnoutSectionHitArea,
} from 'src/graphics/turnout/TurnoutDrawAssistant'; } from 'src/graphics/turnout/TurnoutDrawAssistant';
import { useLineStore } from 'src/stores/line-store'; import { useLineStore } from 'src/stores/line-store';
import { setSwitchPosition } from 'src/api/Simulation'; import { SetSwitchParams, setSwitchPosition } from 'src/api/Simulation';
import { Dialog, Notify } from 'quasar'; import { Dialog, Notify } from 'quasar';
import AddTrainDialog from '../../components/draw-app/dialogs/AddTrainDialog.vue'; import AddTrainDialog from '../../components/draw-app/dialogs/AddTrainDialog.vue';
import { addTrain } from 'src/api/Simulation'; import { addTrain } from 'src/api/Simulation';
import { successNotify } from 'src/utils/CommonNotify'; import { errorNotify, successNotify } from 'src/utils/CommonNotify';
import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting';
import { request } from 'src/protos/request'; import TurnoutOperation from 'src/components/draw-app/dialogs/TurnoutOperation.vue';
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
import { getKmDistance } from '../lineScene'; import { getKmDistance } from '../lineScene';
@ -40,8 +40,7 @@ function getDefaultEndPoint() {
}; };
} }
const setNormalPosition: MenuItemOptions = { name: '定操' }; const setTurnoutParam: MenuItemOptions = { name: '设置参数' };
const setReversePosition: MenuItemOptions = { name: '反操' };
const addTrainConfig: MenuItemOptions = { const addTrainConfig: MenuItemOptions = {
name: '添加列车', name: '添加列车',
@ -49,7 +48,7 @@ const addTrainConfig: MenuItemOptions = {
const TurnoutOperationMenu: ContextMenu = ContextMenu.init({ const TurnoutOperationMenu: ContextMenu = ContextMenu.init({
name: 'Turnout操作', name: 'Turnout操作',
groups: [{ items: [setNormalPosition, setReversePosition, addTrainConfig] }], groups: [{ items: [setTurnoutParam, addTrainConfig] }],
}); });
export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> { export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> {
@ -96,20 +95,29 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> {
this.app.updateSelected(turnout); this.app.updateSelected(turnout);
const simulationId = useLineStore().simulationId || ''; const simulationId = useLineStore().simulationId || '';
const mapId = useLineStore().mapId as number; const mapId = useLineStore().mapId as number;
const setPosition = async (val: number) => { setTurnoutParam.handler = async () => {
await setSwitchPosition({ Dialog.create({
title: '道岔设置参数',
message: '',
component: TurnoutOperation,
componentProps: {
code: turnout.datas.code,
},
cancel: true,
persistent: true,
}).onOk((data) => {
const obj: SetSwitchParams = {
simulationId, simulationId,
mapId, mapId,
deviceId: turnout.datas.id, deviceId: turnout.id,
operation: val, operation: data.operation,
param: { forcePosition: data.forcePosition },
};
setSwitchPosition(obj).catch((e) =>
errorNotify('道岔操作失败:' + e.title, e)
);
}); });
}; };
setNormalPosition.handler = async () => {
await setPosition(request.Turnout.Operation.DC);
};
setReversePosition.handler = async () => {
await setPosition(request.Turnout.Operation.FC);
};
const port = (target as TurnoutSection).port; const port = (target as TurnoutSection).port;
addTrainConfig.disabled = !port || !useLineStore().trainConfigList; addTrainConfig.disabled = !port || !useLineStore().trainConfigList;

View File

@ -4218,6 +4218,7 @@ export namespace state {
id?: number; id?: number;
xh?: boolean; xh?: boolean;
code?: string; code?: string;
force?: 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);
@ -4231,6 +4232,9 @@ export namespace state {
if ("code" in data && data.code != undefined) { if ("code" in data && data.code != undefined) {
this.code = data.code; this.code = data.code;
} }
if ("force" in data && data.force != undefined) {
this.force = data.force;
}
} }
} }
get id() { get id() {
@ -4251,10 +4255,17 @@ export namespace state {
set code(value: string) { set code(value: string) {
pb_1.Message.setField(this, 3, value); pb_1.Message.setField(this, 3, value);
} }
get force() {
return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean;
}
set force(value: boolean) {
pb_1.Message.setField(this, 4, value);
}
static fromObject(data: { static fromObject(data: {
id?: number; id?: number;
xh?: boolean; xh?: boolean;
code?: string; code?: string;
force?: boolean;
}): ReplyState { }): ReplyState {
const message = new ReplyState({}); const message = new ReplyState({});
if (data.id != null) { if (data.id != null) {
@ -4266,6 +4277,9 @@ export namespace state {
if (data.code != null) { if (data.code != null) {
message.code = data.code; message.code = data.code;
} }
if (data.force != null) {
message.force = data.force;
}
return message; return message;
} }
toObject() { toObject() {
@ -4273,6 +4287,7 @@ export namespace state {
id?: number; id?: number;
xh?: boolean; xh?: boolean;
code?: string; code?: string;
force?: boolean;
} = {}; } = {};
if (this.id != null) { if (this.id != null) {
data.id = this.id; data.id = this.id;
@ -4283,6 +4298,9 @@ export namespace state {
if (this.code != null) { if (this.code != null) {
data.code = this.code; data.code = this.code;
} }
if (this.force != null) {
data.force = this.force;
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
@ -4295,6 +4313,8 @@ export namespace state {
writer.writeBool(2, this.xh); writer.writeBool(2, this.xh);
if (this.code.length) if (this.code.length)
writer.writeString(3, this.code); writer.writeString(3, this.code);
if (this.force != false)
writer.writeBool(4, this.force);
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -4313,6 +4333,9 @@ export namespace state {
case 3: case 3:
message.code = reader.readString(); message.code = reader.readString();
break; break;
case 4:
message.force = reader.readBool();
break;
default: reader.skipField(); default: reader.skipField();
} }
} }

View File

@ -189,15 +189,15 @@ export namespace request {
return RelayOperationReq.deserialize(bytes); return RelayOperationReq.deserialize(bytes);
} }
} }
export class Turnout extends pb_1.Message { export class Points extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | {}) { constructor(data?: any[] | {}) {
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);
if (!Array.isArray(data) && typeof data == "object") { } if (!Array.isArray(data) && typeof data == "object") { }
} }
static fromObject(data: {}): Turnout { static fromObject(data: {}): Points {
const message = new Turnout({}); const message = new Points({});
return message; return message;
} }
toObject() { toObject() {
@ -211,8 +211,8 @@ export namespace request {
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Turnout { static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Points {
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 Points();
while (reader.nextField()) { while (reader.nextField()) {
if (reader.isEndGroup()) if (reader.isEndGroup())
break; break;
@ -225,33 +225,30 @@ export namespace request {
serializeBinary(): Uint8Array { serializeBinary(): Uint8Array {
return this.serialize(); return this.serialize();
} }
static deserializeBinary(bytes: Uint8Array): Turnout { static deserializeBinary(bytes: Uint8Array): Points {
return Turnout.deserialize(bytes); return Points.deserialize(bytes);
} }
} }
export namespace Turnout { export namespace Points {
export enum Operation { export enum Operation {
Undefined = 0, Undefined = 0,
DC = 1, SetParams = 1
CancelDC = 2, }
FC = 3, export enum Force {
CancelFC = 4, FP_NONE = 0,
SetSB = 5, FP_DW = 1,
CancelSB = 6, FP_FW = 2,
SetJC = 7, FP_SB = 3
CancelJC = 8,
ForceDw = 9,
ForceFw = 10,
CancelForce = 11
} }
} }
export class TurnoutOperationReq extends pb_1.Message { export class PointsOperationReq extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | { constructor(data?: any[] | {
simulationId?: string; simulationId?: string;
mapId?: number; mapId?: number;
deviceId?: number; deviceId?: number;
operation?: Turnout.Operation; operation?: Points.Operation;
param?: PointsParam;
}) { }) {
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);
@ -268,6 +265,9 @@ export namespace request {
if ("operation" in data && data.operation != undefined) { if ("operation" in data && data.operation != undefined) {
this.operation = data.operation; this.operation = data.operation;
} }
if ("param" in data && data.param != undefined) {
this.param = data.param;
}
} }
} }
get simulationId() { get simulationId() {
@ -289,18 +289,28 @@ export namespace request {
pb_1.Message.setField(this, 3, value); pb_1.Message.setField(this, 3, value);
} }
get operation() { get operation() {
return pb_1.Message.getFieldWithDefault(this, 4, Turnout.Operation.Undefined) as Turnout.Operation; return pb_1.Message.getFieldWithDefault(this, 4, Points.Operation.Undefined) as Points.Operation;
} }
set operation(value: Turnout.Operation) { set operation(value: Points.Operation) {
pb_1.Message.setField(this, 4, value); pb_1.Message.setField(this, 4, value);
} }
get param() {
return pb_1.Message.getWrapperField(this, PointsParam, 5) as PointsParam;
}
set param(value: PointsParam) {
pb_1.Message.setWrapperField(this, 5, value);
}
get has_param() {
return pb_1.Message.getField(this, 5) != null;
}
static fromObject(data: { static fromObject(data: {
simulationId?: string; simulationId?: string;
mapId?: number; mapId?: number;
deviceId?: number; deviceId?: number;
operation?: Turnout.Operation; operation?: Points.Operation;
}): TurnoutOperationReq { param?: ReturnType<typeof PointsParam.prototype.toObject>;
const message = new TurnoutOperationReq({}); }): PointsOperationReq {
const message = new PointsOperationReq({});
if (data.simulationId != null) { if (data.simulationId != null) {
message.simulationId = data.simulationId; message.simulationId = data.simulationId;
} }
@ -313,6 +323,9 @@ export namespace request {
if (data.operation != null) { if (data.operation != null) {
message.operation = data.operation; message.operation = data.operation;
} }
if (data.param != null) {
message.param = PointsParam.fromObject(data.param);
}
return message; return message;
} }
toObject() { toObject() {
@ -320,7 +333,8 @@ export namespace request {
simulationId?: string; simulationId?: string;
mapId?: number; mapId?: number;
deviceId?: number; deviceId?: number;
operation?: Turnout.Operation; operation?: Points.Operation;
param?: ReturnType<typeof PointsParam.prototype.toObject>;
} = {}; } = {};
if (this.simulationId != null) { if (this.simulationId != null) {
data.simulationId = this.simulationId; data.simulationId = this.simulationId;
@ -334,6 +348,9 @@ export namespace request {
if (this.operation != null) { if (this.operation != null) {
data.operation = this.operation; data.operation = this.operation;
} }
if (this.param != null) {
data.param = this.param.toObject();
}
return data; return data;
} }
serialize(): Uint8Array; serialize(): Uint8Array;
@ -346,13 +363,15 @@ export namespace request {
writer.writeInt32(2, this.mapId); writer.writeInt32(2, this.mapId);
if (this.deviceId != 0) if (this.deviceId != 0)
writer.writeUint32(3, this.deviceId); writer.writeUint32(3, this.deviceId);
if (this.operation != Turnout.Operation.Undefined) if (this.operation != Points.Operation.Undefined)
writer.writeEnum(4, this.operation); writer.writeEnum(4, this.operation);
if (this.has_param)
writer.writeMessage(5, this.param, () => this.param.serialize(writer));
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): TurnoutOperationReq { static deserialize(bytes: Uint8Array | pb_1.BinaryReader): PointsOperationReq {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TurnoutOperationReq(); const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PointsOperationReq();
while (reader.nextField()) { while (reader.nextField()) {
if (reader.isEndGroup()) if (reader.isEndGroup())
break; break;
@ -369,6 +388,9 @@ export namespace request {
case 4: case 4:
message.operation = reader.readEnum(); message.operation = reader.readEnum();
break; break;
case 5:
reader.readMessage(message.param, () => message.param = PointsParam.deserialize(reader));
break;
default: reader.skipField(); default: reader.skipField();
} }
} }
@ -377,8 +399,75 @@ export namespace request {
serializeBinary(): Uint8Array { serializeBinary(): Uint8Array {
return this.serialize(); return this.serialize();
} }
static deserializeBinary(bytes: Uint8Array): TurnoutOperationReq { static deserializeBinary(bytes: Uint8Array): PointsOperationReq {
return TurnoutOperationReq.deserialize(bytes); return PointsOperationReq.deserialize(bytes);
}
}
export class PointsParam extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
forcePosition?: Points.Force;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("forcePosition" in data && data.forcePosition != undefined) {
this.forcePosition = data.forcePosition;
}
}
}
get forcePosition() {
return pb_1.Message.getFieldWithDefault(this, 1, Points.Force.FP_NONE) as Points.Force;
}
set forcePosition(value: Points.Force) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: {
forcePosition?: Points.Force;
}): PointsParam {
const message = new PointsParam({});
if (data.forcePosition != null) {
message.forcePosition = data.forcePosition;
}
return message;
}
toObject() {
const data: {
forcePosition?: Points.Force;
} = {};
if (this.forcePosition != null) {
data.forcePosition = this.forcePosition;
}
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.forcePosition != Points.Force.FP_NONE)
writer.writeEnum(1, this.forcePosition);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): PointsParam {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PointsParam();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.forcePosition = reader.readEnum();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): PointsParam {
return PointsParam.deserialize(bytes);
} }
} }
export class Signal extends pb_1.Message { export class Signal extends pb_1.Message {
@ -424,17 +513,276 @@ export namespace request {
export namespace Signal { export namespace Signal {
export enum Operation { export enum Operation {
Undefined = 0, Undefined = 0,
Display = 1, SetParams = 1
LightHFaultDs = 2, }
LightUFaultDs = 3, export enum DS {
LightLFaultDs = 4, DS_H = 0,
LightAFaultDs = 5, DS_U = 1,
LightBFaultDs = 6, DS_L = 2,
LightHCancelDs = 7, DS_A = 3,
LightUCancelDs = 8, DS_B = 4
LightLCancelDs = 9, }
LightACancelDs = 10, export enum Force {
LightBCancelDs = 11 SF_NONE = 0,
SF_M = 1,
SF_H = 2,
SF_U = 3,
SF_L = 4,
SF_HU = 5,
SF_A = 6,
SF_B = 7
}
}
export class SignalOperationReq extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
simulationId?: string;
mapId?: number;
deviceId?: number;
operation?: Signal.Operation;
param?: SignalParam;
}) {
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 ("param" in data && data.param != undefined) {
this.param = data.param;
}
}
}
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, 0) as number;
}
set deviceId(value: number) {
pb_1.Message.setField(this, 3, value);
}
get operation() {
return pb_1.Message.getFieldWithDefault(this, 4, Signal.Operation.Undefined) as Signal.Operation;
}
set operation(value: Signal.Operation) {
pb_1.Message.setField(this, 4, value);
}
get param() {
return pb_1.Message.getWrapperField(this, SignalParam, 5) as SignalParam;
}
set param(value: SignalParam) {
pb_1.Message.setWrapperField(this, 5, value);
}
get has_param() {
return pb_1.Message.getField(this, 5) != null;
}
static fromObject(data: {
simulationId?: string;
mapId?: number;
deviceId?: number;
operation?: Signal.Operation;
param?: ReturnType<typeof SignalParam.prototype.toObject>;
}): SignalOperationReq {
const message = new SignalOperationReq({});
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;
}
if (data.param != null) {
message.param = SignalParam.fromObject(data.param);
}
return message;
}
toObject() {
const data: {
simulationId?: string;
mapId?: number;
deviceId?: number;
operation?: Signal.Operation;
param?: ReturnType<typeof SignalParam.prototype.toObject>;
} = {};
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;
}
if (this.param != null) {
data.param = this.param.toObject();
}
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 != 0)
writer.writeUint32(3, this.deviceId);
if (this.operation != Signal.Operation.Undefined)
writer.writeEnum(4, this.operation);
if (this.has_param)
writer.writeMessage(5, this.param, () => this.param.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SignalOperationReq {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SignalOperationReq();
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.readUint32();
break;
case 4:
message.operation = reader.readEnum();
break;
case 5:
reader.readMessage(message.param, () => message.param = SignalParam.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): SignalOperationReq {
return SignalOperationReq.deserialize(bytes);
}
}
export class SignalParam extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
force?: Signal.Force;
dsList?: Signal.DS[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("force" in data && data.force != undefined) {
this.force = data.force;
}
if ("dsList" in data && data.dsList != undefined) {
this.dsList = data.dsList;
}
}
}
get force() {
return pb_1.Message.getFieldWithDefault(this, 1, Signal.Force.SF_NONE) as Signal.Force;
}
set force(value: Signal.Force) {
pb_1.Message.setField(this, 1, value);
}
get dsList() {
return pb_1.Message.getFieldWithDefault(this, 2, []) as Signal.DS[];
}
set dsList(value: Signal.DS[]) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
force?: Signal.Force;
dsList?: Signal.DS[];
}): SignalParam {
const message = new SignalParam({});
if (data.force != null) {
message.force = data.force;
}
if (data.dsList != null) {
message.dsList = data.dsList;
}
return message;
}
toObject() {
const data: {
force?: Signal.Force;
dsList?: Signal.DS[];
} = {};
if (this.force != null) {
data.force = this.force;
}
if (this.dsList != null) {
data.dsList = this.dsList;
}
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.force != Signal.Force.SF_NONE)
writer.writeEnum(1, this.force);
if (this.dsList.length)
writer.writePackedEnum(2, this.dsList);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SignalParam {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SignalParam();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.force = reader.readEnum();
break;
case 2:
message.dsList = reader.readPackedEnum();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): SignalParam {
return SignalParam.deserialize(bytes);
} }
} }
export class Section extends pb_1.Message { export class Section extends pb_1.Message {