diff --git a/bj-rtss-message b/bj-rtss-message index f12288d..f6f49ec 160000 --- a/bj-rtss-message +++ b/bj-rtss-message @@ -1 +1 @@ -Subproject commit f12288dffe11443fbf16c02b9e1f39f3b44ceda2 +Subproject commit f6f49ec19378c9a9845c53bd4425143f654ae59e diff --git a/graphic-pixi b/graphic-pixi index 0a0cb0a..a7debf1 160000 --- a/graphic-pixi +++ b/graphic-pixi @@ -1 +1 @@ -Subproject commit 0a0cb0a77afd9783081c2dc6ba19687b0b3aa0f7 +Subproject commit a7debf165e24e6200d7c986555f31c721792af38 diff --git a/src/drawApp/graphics/TurnoutInteraction.ts b/src/drawApp/graphics/TurnoutInteraction.ts index 0fa716e..2ee0e90 100644 --- a/src/drawApp/graphics/TurnoutInteraction.ts +++ b/src/drawApp/graphics/TurnoutInteraction.ts @@ -1,9 +1,14 @@ -import { ITurnoutData, Turnout } from 'src/graphics/turnout/Turnout'; +import { + ITurnoutData, + ITurnoutState, + Turnout, +} from 'src/graphics/turnout/Turnout'; import * as pb_1 from 'google-protobuf'; -import { GraphicDataBase } from './GraphicDataBase'; +import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase'; import { graphicData } from 'src/protos/stationLayoutGraphics'; import { IPointData } from 'pixi.js'; import { KilometerSystem } from 'src/graphics/signal/Signal'; +import { state } from 'src/protos/device_status'; function getDefaultEndPoint() { return { @@ -91,3 +96,59 @@ export class TurnoutData extends GraphicDataBase implements ITurnoutData { return pb_1.Message.equals(this.data, other.data); } } + +export class TurnoutStates extends GraphicStateBase implements ITurnoutState { + constructor(proto?: state.Switch) { + let states; + if (proto) { + states = proto; + } else { + states = new state.Switch(); + } + super(states, Turnout.Type); + } + get code(): string { + return this.states.id; + } + ipSingleSwitchStusCiOccupied?: boolean; + ipSingleSwitchStusCbtcOccupied?: boolean; + ipSingleSwitchStusLocked?: boolean; + ipSingleSwitchStusFailLocked?: boolean; + ipSingleSwitchStusNormal?: boolean; + ipSingleSwitchStusReverse?: boolean; + ipSingleSwitchStusBlocked1?: boolean; + ipSingleSwitchStusJammed?: boolean; + ipSingleSwitchStusExpectLock?: boolean; + ipSingleSwitchStusExpectUnlock?: boolean; + ipSingleSwitchStusExpectNormal?: boolean; + ipSingleSwitchStusExpectReverse?: boolean; + ipSingleSwitchStusExpectBlock?: boolean; + ipSingleSwitchStusExpectUnblock?: boolean; + ipSingleSwitchStusInRoute?: boolean; + ipSingleSwitchStusManualMode?: boolean; + ipSingleSwitchStusCut?: boolean; + ipSingleSwitchStusAtcInvalid?: boolean; + ipSingleSwitchStusOverlap?: boolean; + ipSingleSwitchStusTsrCbtcMain?: boolean; + ipSingleSwitchStusTsrCbtcNormal?: boolean; + ipSingleSwitchStusTsrCbtcReverse?: boolean; + ipSingleSwitchStusTsrBmMain?: boolean; + ipSingleSwitchStusTsrBmNormal?: boolean; + ipSingleSwitchStusTsrBmReverse?: boolean; + ipSingleSwitchStusBlocked2?: boolean; + ipSingleSwitchStusLostIndication?: boolean; + id?: string; + speedLimit?: number; + get states(): state.Switch { + return this.getState(); + } + clone(): TurnoutStates { + return new TurnoutStates(this.states.cloneMessage()); + } + copyFrom(data: GraphicStateBase): void { + pb_1.Message.copyInto(data._state, this._state); + } + eq(data: GraphicStateBase): boolean { + return pb_1.Message.equals(this._state, data._state); + } +} diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index fd0b78d..04db814 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -54,7 +54,7 @@ import { AxleCountingSectionDraw } from 'src/graphics/axleCountingSection/AxleCo import { AxleCountingSectionData } from './graphics/AxleCountingSectionInteraction'; import { Turnout, TurnoutTemplate } from 'src/graphics/turnout/Turnout'; import { TurnoutDraw } from 'src/graphics/turnout/TurnoutDrawAssistant'; -import { TurnoutData } from './graphics/TurnoutInteraction'; +import { TurnoutData, TurnoutStates } from './graphics/TurnoutInteraction'; import { saveDraft, getDraft } from 'src/api/DraftApi'; import { useDrawStore } from 'src/stores/draw-store'; import { successNotify, errorNotify } from '../utils/CommonNotify'; @@ -195,7 +195,10 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { ), new TrainDraw(app, new TrainTemplate(new TrainData(), new TrainState())), new SectionDraw(app, new SectionTemplate(new SectionData())), - new TurnoutDraw(app, new TurnoutTemplate(new TurnoutData())), + new TurnoutDraw( + app, + new TurnoutTemplate(new TurnoutData(), new TurnoutStates()) + ), new TrainWindowDraw(app, new TrainWindowTemplate(new TrainWindowData())), new OneClickGenerateDraw(app, new OneClickGenerateTemplate()), new AxleCountingDraw( diff --git a/src/drawApp/lineApp.ts b/src/drawApp/lineApp.ts index caf08b2..300eb22 100644 --- a/src/drawApp/lineApp.ts +++ b/src/drawApp/lineApp.ts @@ -25,7 +25,7 @@ import { StationState, } from './graphics/StationInteraction'; import { Station, StationTemplate } from 'src/graphics/station/Station'; -import { TurnoutData } from './graphics/TurnoutInteraction'; +import { TurnoutData, TurnoutStates } from './graphics/TurnoutInteraction'; import { TurnoutTemplate } from 'src/graphics/turnout/Turnout'; import { SectionData } from './graphics/SectionInteraction'; import { SectionTemplate } from 'src/graphics/section/Section'; @@ -71,7 +71,7 @@ export function initLineApp(dom: HTMLElement): GraphicApp { new SignalTemplate(new SignalData(), new SignalState()), new PlatformTemplate(new PlatformData(), new PlatformState()), new StationTemplate(new StationData(), new StationState()), - new TurnoutTemplate(new TurnoutData()), + new TurnoutTemplate(new TurnoutData(), new TurnoutStates()), new SectionTemplate(new SectionData()), new AxleCountingTemplate(new AxleCountingData()), new TrainWindowTemplate(new TrainWindowData()), diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index a0da3ce..c2202db 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -132,49 +132,53 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< } } }); - const fourTurnout: Turnout[] = []; + const fourAxleCounting: AxleCounting[] = []; hasfourTurnout.forEach((axleCountings) => { - const axleCountingRelations = - axleCountings[0].relationManage.getRelationsOfGraphicAndOtherType( - axleCountings[0], - Turnout.Type - ); - axleCountingRelations.forEach((relation) => { - const refDevice = relation.getOtherGraphic
(axleCountings[0]); - fourTurnout; + axleCountings.forEach((axleCounting) => { + //计轴关联的道岔 + const axleCountingRelations = + axleCounting.relationManage.getRelationsOfGraphicAndOtherType( + axleCounting, + Turnout.Type + ); + axleCountingRelations.forEach((relation) => { + const refTurnout = relation.getOtherGraphic(axleCounting); + //道岔关联的计轴 + const turnoutRelations = + refTurnout.relationManage.getRelationsOfGraphicAndOtherType( + refTurnout, + AxleCounting.Type + ); + turnoutRelations.forEach((relation) => { + const refAxleCounting = + relation.getOtherGraphic(refTurnout); + if ( + refAxleCounting.id !== axleCountings[0].id && + refAxleCounting.id !== axleCountings[1].id + ) { + fourAxleCounting.push(refAxleCounting); + } + }); + }); }); }); - - /* axleCountings.sort((a, b) => a.x - b.x); - const downAxleCountings = axleCountings.filter((point) => { - return point.y > 350; - }); - for (let i = 0; i < downAxleCountings.length - 1; i++) { - const firstRef = downAxleCountings[i].datas.axleCountingRef.map( - (ref) => ref.id - ); - const nextRef = downAxleCountings[i + 1].datas.axleCountingRef.map( - (ref) => ref.id - ); - let nextNextRef: string[] = []; - if (i + 2 < downAxleCountings.length) { - nextNextRef = downAxleCountings[i + 2].datas.axleCountingRef.map( - (ref) => ref.id - ); + for (let x = 0; x < fourAxleCounting.length; x += 4) { + const AxleCountings = fourAxleCounting.slice(x, x + 4); + for (let y = 0; y < 4; y++) { + if (fourAxleCounting[x].id == AxleCountings[y].id) continue; + if (fourAxleCounting[x].y == AxleCountings[y].y) { + this.draw([fourAxleCounting[x], AxleCountings[y]]); + break; + } } - if (hasCommonElements(firstRef, nextRef)) { - this.draw([downAxleCountings[i], downAxleCountings[i + 1]]); - } else if ( - hasSamePosition( - downAxleCountings[i + 1].position, - downAxleCountings[i + 2].position - ) && - hasCommonElements(firstRef, nextNextRef) - ) { - this.draw([downAxleCountings[i], downAxleCountings[i + 2]]); - i += 2; + for (let y = 0; y < 4; y++) { + if (fourAxleCounting[x + 1].id == AxleCountings[y].id) continue; + if (fourAxleCounting[x + 1].y == AxleCountings[y].y) { + this.draw([fourAxleCounting[x + 1], AxleCountings[y]]); + break; + } } - } */ + } } } diff --git a/src/graphics/turnout/Turnout.ts b/src/graphics/turnout/Turnout.ts index b1dfef7..f8b8e3c 100644 --- a/src/graphics/turnout/Turnout.ts +++ b/src/graphics/turnout/Turnout.ts @@ -40,11 +40,46 @@ export interface ITurnoutData extends GraphicData { eq(other: ITurnoutData): boolean; } +export interface ITurnoutState extends GraphicState { + ipSingleSwitchStusCiOccupied?: boolean; + ipSingleSwitchStusCbtcOccupied?: boolean; + ipSingleSwitchStusLocked?: boolean; + ipSingleSwitchStusFailLocked?: boolean; + ipSingleSwitchStusNormal?: boolean; + ipSingleSwitchStusReverse?: boolean; + ipSingleSwitchStusBlocked1?: boolean; + ipSingleSwitchStusJammed?: boolean; + ipSingleSwitchStusExpectLock?: boolean; + ipSingleSwitchStusExpectUnlock?: boolean; + ipSingleSwitchStusExpectNormal?: boolean; + ipSingleSwitchStusExpectReverse?: boolean; + ipSingleSwitchStusExpectBlock?: boolean; + ipSingleSwitchStusExpectUnblock?: boolean; + ipSingleSwitchStusInRoute?: boolean; + ipSingleSwitchStusManualMode?: boolean; + ipSingleSwitchStusCut?: boolean; + ipSingleSwitchStusAtcInvalid?: boolean; + ipSingleSwitchStusOverlap?: boolean; + ipSingleSwitchStusTsrCbtcMain?: boolean; + ipSingleSwitchStusTsrCbtcNormal?: boolean; + ipSingleSwitchStusTsrCbtcReverse?: boolean; + ipSingleSwitchStusTsrBmMain?: boolean; + ipSingleSwitchStusTsrBmNormal?: boolean; + ipSingleSwitchStusTsrBmReverse?: boolean; + ipSingleSwitchStusBlocked2?: boolean; + ipSingleSwitchStusLostIndication?: boolean; + id?: string; + speedLimit?: number; +} + export const TurnoutConsts = { lineColor: '#5578b6', lineWidth: 5, forkLenth: 20, labelFontSize: 12, + normalLabelColor: '#0f0', + reverseLabelColor: '#ff0', + transformingAndJammedColor: '#f00', }; export enum TurnoutPosition { @@ -58,10 +93,6 @@ export enum TurnoutPort { C = 'C', } -export interface ITurnoutState extends GraphicState { - position: TurnoutPosition; -} - export function getForkPoint(r: number, p: IPointData): IPointData { if (r === 0) return { x: 0, y: 0 }; const len = Math.sqrt((-p.x) ** 2 + (-p.y) ** 2); @@ -166,8 +197,14 @@ export class Turnout extends JlGraphic { } doRepaint(): void { - const { pointB } = this.datas; - this.graphics.fork.paint(pointB[0]); + const { pointB, pointC } = this.datas; + if (this.states.ipSingleSwitchStusNormal) { + this.graphics.fork.paint(pointB[0]); + this.graphics.label.style.stroke = TurnoutConsts.normalLabelColor; + } else if (this.states.ipSingleSwitchStusReverse) { + this.graphics.fork.paint(pointC[0]); + this.graphics.label.style.stroke = TurnoutConsts.reverseLabelColor; + } this.graphics.sections.forEach((sectionGraphic) => sectionGraphic.paint()); @@ -351,7 +388,7 @@ export class TurnoutTemplate extends JlGraphicTemplate { new() { const g = new Turnout(); g.loadData(this.datas); - // g.loadState(this.states); + g.loadState(this.states); return g; } } diff --git a/src/jl-graphic/app/JlGraphicApp.ts b/src/jl-graphic/app/JlGraphicApp.ts index c2b0af8..e073582 100644 --- a/src/jl-graphic/app/JlGraphicApp.ts +++ b/src/jl-graphic/app/JlGraphicApp.ts @@ -528,7 +528,10 @@ export class GraphicApp extends EventEmitter { */ handleGraphicStates(graphicStates: GraphicState[]) { graphicStates.forEach((state) => { - const list = this.queryStore.queryByIdOrCode(state.code); + const list = this.queryStore.queryByIdOrCodeAndType( + state.code, + state.graphicType + ); if (list.length == 0) { const template = this.getGraphicTemplatesByType(state.graphicType); const g = template.new(); diff --git a/src/jl-graphic/core/GraphicStore.ts b/src/jl-graphic/core/GraphicStore.ts index 979bd20..23e8889 100644 --- a/src/jl-graphic/core/GraphicStore.ts +++ b/src/jl-graphic/core/GraphicStore.ts @@ -37,6 +37,12 @@ export interface GraphicQueryStore { * @param v */ queryByIdOrCode(v: string): JlGraphic[]; + /** + * 根据id或code及类型查询图形 + * @param v + * @param type + */ + queryByIdOrCodeAndType(v: string, type: string): JlGraphic[]; /** * 根据code和类型获取图形 * @param code @@ -69,6 +75,7 @@ export class GraphicStore implements GraphicQueryStore { this.store = new Map(); this.relationManage = new RelationManage(app); } + /** * 获取所有图形对象 */ @@ -125,6 +132,15 @@ export class GraphicStore implements GraphicQueryStore { }); return list; } + queryByIdOrCodeAndType(s: string, type: string): JlGraphic[] { + const list: JlGraphic[] = []; + this.store.forEach((g) => { + if (g.isIdOrCode(s) && g.type === type) { + list.push(g); + } + }); + return list; + } queryByCodeAndType( code: string, type: string diff --git a/src/jl-graphic/plugins/GraphicEditPlugin.ts b/src/jl-graphic/plugins/GraphicEditPlugin.ts index 9b1cc5b..c93631a 100644 --- a/src/jl-graphic/plugins/GraphicEditPlugin.ts +++ b/src/jl-graphic/plugins/GraphicEditPlugin.ts @@ -32,13 +32,13 @@ export abstract class GraphicEditPlugin< this.sortableChildren = true; this.graphic.on('transformstart', this.hideAll, this); this.graphic.on('transformend', this.showAll, this); - this.graphic.on('repaint', this.showAll, this); + this.graphic.on('repaint', this.updateEditedPointsPosition, this); } destroy(options?: boolean | IDestroyOptions | undefined): void { this.graphic.off('transformstart', this.hideAll, this); this.graphic.off('transformend', this.showAll, this); - this.graphic.off('repaint', this.showAll, this); + this.graphic.off('repaint', this.updateEditedPointsPosition, this); super.destroy(options); } diff --git a/src/protos/device_state.ts b/src/protos/device_state.ts new file mode 100644 index 0000000..fa49ba8 --- /dev/null +++ b/src/protos/device_state.ts @@ -0,0 +1,512 @@ +/** + * Generated by the protoc-gen-ts. DO NOT EDIT! + * compiler version: 4.23.1 + * source: device_state.proto + * git: https://github.com/thesayyn/protoc-gen-ts */ +import * as pb_1 from "google-protobuf"; +export namespace state { + export enum SectionType { + Any = 0, + Axle = 1, + Logic = 2, + Physic = 3 + } + export class LinkState extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + id?: string; + trainId?: string[]; + }) { + 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 ("id" in data && data.id != undefined) { + this.id = data.id; + } + if ("trainId" in data && data.trainId != undefined) { + this.trainId = data.trainId; + } + } + } + get id() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + set id(value: string) { + pb_1.Message.setField(this, 1, value); + } + get trainId() { + return pb_1.Message.getFieldWithDefault(this, 2, []) as string[]; + } + set trainId(value: string[]) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + id?: string; + trainId?: string[]; + }): LinkState { + const message = new LinkState({}); + if (data.id != null) { + message.id = data.id; + } + if (data.trainId != null) { + message.trainId = data.trainId; + } + return message; + } + toObject() { + const data: { + id?: string; + trainId?: string[]; + } = {}; + if (this.id != null) { + data.id = this.id; + } + if (this.trainId != null) { + data.trainId = this.trainId; + } + 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.id.length) + writer.writeString(1, this.id); + if (this.trainId.length) + writer.writeRepeatedString(2, this.trainId); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): LinkState { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new LinkState(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.id = 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): LinkState { + return LinkState.deserialize(bytes); + } + } + export class SectionState extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + id?: string; + type?: SectionType; + occupied?: boolean; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + 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; + } + } + } + get id() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + 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); + } + static fromObject(data: { + id?: string; + type?: SectionType; + occupied?: 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; + } + return message; + } + toObject() { + const data: { + id?: string; + type?: SectionType; + occupied?: 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; + } + 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.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 (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SectionState { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SectionState(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.id = reader.readString(); + break; + case 2: + message.type = reader.readEnum(); + break; + case 3: + message.occupied = reader.readBool(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): SectionState { + return SectionState.deserialize(bytes); + } + } + export class SwitchState extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + id?: string; + normal?: boolean; + reverse?: boolean; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("id" in data && data.id != undefined) { + this.id = data.id; + } + if ("normal" in data && data.normal != undefined) { + this.normal = data.normal; + } + if ("reverse" in data && data.reverse != undefined) { + this.reverse = data.reverse; + } + } + } + get id() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + set id(value: string) { + pb_1.Message.setField(this, 1, value); + } + get normal() { + return pb_1.Message.getFieldWithDefault(this, 2, false) as boolean; + } + set normal(value: boolean) { + pb_1.Message.setField(this, 2, value); + } + get reverse() { + return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean; + } + set reverse(value: boolean) { + pb_1.Message.setField(this, 3, value); + } + static fromObject(data: { + id?: string; + normal?: boolean; + reverse?: boolean; + }): SwitchState { + const message = new SwitchState({}); + if (data.id != null) { + message.id = data.id; + } + if (data.normal != null) { + message.normal = data.normal; + } + if (data.reverse != null) { + message.reverse = data.reverse; + } + return message; + } + toObject() { + const data: { + id?: string; + normal?: boolean; + reverse?: boolean; + } = {}; + if (this.id != null) { + data.id = this.id; + } + if (this.normal != null) { + data.normal = this.normal; + } + if (this.reverse != null) { + data.reverse = this.reverse; + } + 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.id.length) + writer.writeString(1, this.id); + if (this.normal != false) + writer.writeBool(2, this.normal); + if (this.reverse != false) + writer.writeBool(3, this.reverse); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SwitchState { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SwitchState(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.id = reader.readString(); + break; + case 2: + message.normal = reader.readBool(); + break; + case 3: + message.reverse = reader.readBool(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): SwitchState { + return SwitchState.deserialize(bytes); + } + } + export class TrainState extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + id?: string; + headLinkId?: string; + headLinkOffset?: number; + tailLinkId?: string; + tailLinkOffset?: number; + occupiedLinkId?: string[]; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [6], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("id" in data && data.id != undefined) { + this.id = data.id; + } + if ("headLinkId" in data && data.headLinkId != undefined) { + this.headLinkId = data.headLinkId; + } + if ("headLinkOffset" in data && data.headLinkOffset != undefined) { + this.headLinkOffset = data.headLinkOffset; + } + if ("tailLinkId" in data && data.tailLinkId != undefined) { + this.tailLinkId = data.tailLinkId; + } + if ("tailLinkOffset" in data && data.tailLinkOffset != undefined) { + this.tailLinkOffset = data.tailLinkOffset; + } + if ("occupiedLinkId" in data && data.occupiedLinkId != undefined) { + this.occupiedLinkId = data.occupiedLinkId; + } + } + } + get id() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + set id(value: string) { + pb_1.Message.setField(this, 1, value); + } + get headLinkId() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set headLinkId(value: string) { + pb_1.Message.setField(this, 2, value); + } + get headLinkOffset() { + return pb_1.Message.getFieldWithDefault(this, 3, 0) as number; + } + set headLinkOffset(value: number) { + pb_1.Message.setField(this, 3, value); + } + get tailLinkId() { + return pb_1.Message.getFieldWithDefault(this, 4, "") as string; + } + set tailLinkId(value: string) { + pb_1.Message.setField(this, 4, value); + } + get tailLinkOffset() { + return pb_1.Message.getFieldWithDefault(this, 5, 0) as number; + } + set tailLinkOffset(value: number) { + pb_1.Message.setField(this, 5, value); + } + get occupiedLinkId() { + return pb_1.Message.getFieldWithDefault(this, 6, []) as string[]; + } + set occupiedLinkId(value: string[]) { + pb_1.Message.setField(this, 6, value); + } + static fromObject(data: { + id?: string; + headLinkId?: string; + headLinkOffset?: number; + tailLinkId?: string; + tailLinkOffset?: number; + occupiedLinkId?: string[]; + }): TrainState { + const message = new TrainState({}); + if (data.id != null) { + message.id = data.id; + } + if (data.headLinkId != null) { + message.headLinkId = data.headLinkId; + } + if (data.headLinkOffset != null) { + message.headLinkOffset = data.headLinkOffset; + } + if (data.tailLinkId != null) { + message.tailLinkId = data.tailLinkId; + } + if (data.tailLinkOffset != null) { + message.tailLinkOffset = data.tailLinkOffset; + } + if (data.occupiedLinkId != null) { + message.occupiedLinkId = data.occupiedLinkId; + } + return message; + } + toObject() { + const data: { + id?: string; + headLinkId?: string; + headLinkOffset?: number; + tailLinkId?: string; + tailLinkOffset?: number; + occupiedLinkId?: string[]; + } = {}; + if (this.id != null) { + data.id = this.id; + } + if (this.headLinkId != null) { + data.headLinkId = this.headLinkId; + } + if (this.headLinkOffset != null) { + data.headLinkOffset = this.headLinkOffset; + } + if (this.tailLinkId != null) { + data.tailLinkId = this.tailLinkId; + } + if (this.tailLinkOffset != null) { + data.tailLinkOffset = this.tailLinkOffset; + } + if (this.occupiedLinkId != null) { + data.occupiedLinkId = this.occupiedLinkId; + } + 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.id.length) + writer.writeString(1, this.id); + if (this.headLinkId.length) + writer.writeString(2, this.headLinkId); + if (this.headLinkOffset != 0) + writer.writeInt64(3, this.headLinkOffset); + if (this.tailLinkId.length) + writer.writeString(4, this.tailLinkId); + if (this.tailLinkOffset != 0) + writer.writeInt64(5, this.tailLinkOffset); + if (this.occupiedLinkId.length) + writer.writeRepeatedString(6, this.occupiedLinkId); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): TrainState { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TrainState(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.id = reader.readString(); + break; + case 2: + message.headLinkId = reader.readString(); + break; + case 3: + message.headLinkOffset = reader.readInt64(); + break; + case 4: + message.tailLinkId = reader.readString(); + break; + case 5: + message.tailLinkOffset = reader.readInt64(); + break; + case 6: + pb_1.Message.addToRepeatedField(message, 6, reader.readString()); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): TrainState { + return TrainState.deserialize(bytes); + } + } +}