diff --git a/src/components/draw-app/DrawProperties.vue b/src/components/draw-app/DrawProperties.vue index 61d68b7..31f4a2b 100644 --- a/src/components/draw-app/DrawProperties.vue +++ b/src/components/draw-app/DrawProperties.vue @@ -81,6 +81,9 @@ + @@ -108,12 +111,13 @@ import TurnoutProperty from './properties/TurnoutProperty.vue'; import SectionProperty from './properties/SectionProperty.vue'; import RunLineProperty from './properties/RunLineProperty.vue'; import PathLineProperty from './properties/PathLineProperty.vue'; +import SeparatorProperty from './properties/SeparatorProperty.vue'; import { Link } from 'src/graphics/link/Link'; import { Rect } from 'src/graphics/rect/Rect'; import { Platform } from 'src/graphics/platform/Platform'; import { Station } from 'src/graphics/station/Station'; import { StationLine } from 'src/graphics/stationLine/StationLine'; -import { Train } from 'src/graphics/train/Train'; +// import { Train } from 'src/graphics/train/Train'; import { useDrawStore } from 'src/stores/draw-store'; import { IscsFan } from 'src/graphics/iscs-fan/IscsFan'; import { Signal } from 'src/graphics/signal/Signal'; @@ -123,6 +127,7 @@ import { Section } from 'src/graphics/section/Section'; import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow'; import { PathLine } from 'src/graphics/pathLine/PathLine'; import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; +import { Separator } from 'src/graphics/separator/Separator'; const drawStore = useDrawStore(); diff --git a/src/components/draw-app/properties/SeparatorProperty.vue b/src/components/draw-app/properties/SeparatorProperty.vue new file mode 100644 index 0000000..5785cc1 --- /dev/null +++ b/src/components/draw-app/properties/SeparatorProperty.vue @@ -0,0 +1,55 @@ + + + diff --git a/src/drawApp/graphics/SeparatorInteraction.ts b/src/drawApp/graphics/SeparatorInteraction.ts new file mode 100644 index 0000000..303ca13 --- /dev/null +++ b/src/drawApp/graphics/SeparatorInteraction.ts @@ -0,0 +1,43 @@ +import * as pb_1 from 'google-protobuf'; +import { ISeparatorData, Separator } from 'src/graphics/separator/Separator'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { GraphicDataBase } from './GraphicDataBase'; + +export class SeparatorData extends GraphicDataBase implements ISeparatorData { + constructor(data?: graphicData.Separator) { + let separator; + if (!data) { + separator = new graphicData.Separator({ + common: GraphicDataBase.defaultCommonInfo(Separator.Type), + }); + } else { + separator = data; + } + super(separator); + } + + public get data(): graphicData.Separator { + return this.getData(); + } + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + get separatorType(): string { + return this.data.separatorType; + } + set separatorType(v: string) { + this.data.separatorType = v; + } + clone(): SeparatorData { + return new SeparatorData(this.data.cloneMessage()); + } + copyFrom(data: SeparatorData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: SeparatorData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/graphics/TrainInteraction.ts b/src/drawApp/graphics/TrainInteraction.ts index 83d5a1e..95d7f42 100644 --- a/src/drawApp/graphics/TrainInteraction.ts +++ b/src/drawApp/graphics/TrainInteraction.ts @@ -4,6 +4,14 @@ import { graphicData } from 'src/protos/stationLayoutGraphics'; import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase'; import { state } from 'src/protos/device_status'; import { train } from 'src/protos/train'; +import { MenuItemOptions } from 'src/jl-graphic/ui/Menu'; +import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; +import { + GraphicApp, + GraphicInteractionPlugin, + JlGraphic, +} from 'src/jl-graphic'; +import { DisplayObject, FederatedMouseEvent } from 'pixi.js'; export class TrainData extends GraphicDataBase implements ITrainData { constructor(data?: graphicData.Train) { @@ -202,3 +210,87 @@ class StateTrain extends train.TrainInfo { } } } + +const negativeDirectionConfig: MenuItemOptions = { + name: '反方向运行', +}; +const HoldTrainConfig: MenuItemOptions = { + name: '扣车', +}; +const openDoorConfig: MenuItemOptions = { + name: '开门', +}; +const editGroupConfig: MenuItemOptions = { + name: '修改车组号', +}; +const TrainOperateMenu: ContextMenu = ContextMenu.init({ + name: '列车操作菜单', + groups: [ + { + items: [ + negativeDirectionConfig, + HoldTrainConfig, + openDoorConfig, + editGroupConfig, + ], + }, + ], +}); + +export class TrainOperateInteraction extends GraphicInteractionPlugin { + static Name = 'train_operate_menu'; + constructor(app: GraphicApp) { + super(TrainOperateInteraction.Name, app); + app.registerMenu(TrainOperateMenu); + } + static init(app: GraphicApp) { + return new TrainOperateInteraction(app); + } + filter(...grahpics: JlGraphic[]): Train[] | undefined { + return grahpics.filter((g) => g.type === Train.Type).map((g) => g as Train); + } + bind(g: Train): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.selectable = true; + g.on('_rightclick', this.onContextMenu, this); + } + + unbind(g: Train): void { + g.selectable = false; + g.eventMode = 'none'; + g.off('_rightclick', this.onContextMenu, this); + } + + onContextMenu(e: FederatedMouseEvent) { + const target = e.target as DisplayObject; + const train = target.getGraphic() as Train; + this.app.updateSelected(train); + negativeDirectionConfig.handler = () => { + const mode = train.states.mode; + if (!train.states.mode.ipModeTrainDirUp) { + mode.ipModeTrainDirUp = true; + mode.ipModeTrainDirDown = false; + } else if (!train.states.mode.ipModeTrainDirDown) { + mode.ipModeTrainDirUp = false; + mode.ipModeTrainDirDown = true; + } + train.chagneDirection(); + }; + HoldTrainConfig.handler = () => { + train.states.mode.ipModeTrainHolded = + !train.states.mode.ipModeTrainHolded; + train.chagneState(); + }; + openDoorConfig.handler = () => { + train.states.mode.ipModeTrainDoorOpen = + !train.states.mode.ipModeTrainDoorOpen; + train.chagneState(); + }; + editGroupConfig.handler = () => { + train.states.trainId = '022'; + train.doRepaint(); + }; + TrainOperateMenu.open(e.global); + } +} diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 76733af..b45f48e 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -79,6 +79,9 @@ import { PathLine, PathLineTemplate } from 'src/graphics/pathLine/PathLine'; import { PathLineDraw } from 'src/graphics/pathLine/PathLineDrawAssistant'; import { PathLineData } from './graphics/PathLineInteraction'; import { toStorageTransform } from './graphics/GraphicDataBase'; +import { SeparatorDraw } from 'src/graphics/separator/SeparatorDrawAssistant'; +import { Separator, SeparatorTemplate } from 'src/graphics/separator/Separator'; +import { SeparatorData } from './graphics/SeparatorInteraction'; // export function fromStoragePoint(p: graphicData.Point): Point { // return new Point(p.x, p.y); @@ -165,6 +168,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { | TrainDraw | OneClickGenerateDraw | AxleCountingDraw + | SeparatorDraw )[] = []; if (draftType === 'Line') { drawAssistants = [ @@ -189,6 +193,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { app, new AxleCountingTemplate(new AxleCountingData()) ), + new SeparatorDraw(app, new SeparatorTemplate(new SeparatorData())), ]; DrawSignalInteraction.init(app); } else { @@ -305,6 +310,9 @@ export function saveDrawDatas(app: JlDrawApp) { } else if (AxleCounting.Type === g.type) { const axleCountingData = (g as AxleCounting).saveData(); storage.axleCountings.push((axleCountingData as AxleCountingData).data); + } else if (Separator.Type === g.type) { + const separatorData = (g as Separator).saveData(); + storage.separators.push((separatorData as SeparatorData).data); } }); const base64 = fromUint8Array(storage.serialize()); @@ -375,6 +383,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.axleCountings.forEach((axleCounting) => { datas.push(new AxleCountingData(axleCounting)); }); + storage.separators.forEach((separator) => { + datas.push(new SeparatorData(separator)); + }); app.loadGraphic(datas); } else { app.loadGraphic([]); diff --git a/src/graphics/separator/Separator.ts b/src/graphics/separator/Separator.ts new file mode 100644 index 0000000..5a7e27d --- /dev/null +++ b/src/graphics/separator/Separator.ts @@ -0,0 +1,90 @@ +import { Color, Graphics } from 'pixi.js'; +import { GraphicData, JlGraphic, JlGraphicTemplate } from 'src/jl-graphic'; + +export interface ISeparatorData extends GraphicData { + get code(): string; // 编号 + set code(v: string); + get separatorType(): string; // 类型 + set separatorType(v: string); + clone(): ISeparatorData; + copyFrom(data: ISeparatorData): void; + eq(other: ISeparatorData): boolean; +} + +export enum separatorTypeEnum { + turnout = 'turnout', // 道岔分隔符 + endA = 'endA', // A端尽头分隔符 + endB = 'endB', // B端尽头分隔符 + section = 'section', // 区段分隔符 +} + +export const SeparatorConsts = { + height: 15, + lineWidth: 2, + lineColor: '0x617799', + circleColor: '0xEF0200', + radius: 5, +}; + +export class Separator extends JlGraphic { + static Type = 'Separator'; + rectGraphic: Graphics = new Graphics(); + circleGraphic: Graphics = new Graphics(); + constructor() { + super(Separator.Type); + this.addChild(this.rectGraphic); + this.addChild(this.circleGraphic); + } + get datas(): ISeparatorData { + return this.getDatas(); + } + doRepaint(): void { + const rectGraphic = this.rectGraphic; + rectGraphic.clear(); + if (!this.datas.separatorType) { + this.datas.separatorType = separatorTypeEnum.endA; + } + const typeArr = ['section', 'turnout']; + if (typeArr.includes(this.datas.separatorType)) { + rectGraphic.lineStyle( + SeparatorConsts.lineWidth, + new Color(SeparatorConsts.lineColor) + ); + rectGraphic.moveTo(0, -SeparatorConsts.height / 2); + rectGraphic.lineTo(0, SeparatorConsts.height / 2); + if (this.datas.separatorType == 'turnout') { + this.circleGraphic.lineStyle(1, SeparatorConsts.circleColor); + this.circleGraphic.drawCircle(0, 0, SeparatorConsts.radius); + } + } + const endTypeArr = ['endA', 'endB']; + if (endTypeArr.includes(this.datas.separatorType)) { + let d = SeparatorConsts.radius; + if (this.datas.separatorType == 'endB') { + d = -d; + } + rectGraphic.lineStyle( + SeparatorConsts.lineWidth, + new Color(SeparatorConsts.lineColor) + ); + rectGraphic.moveTo(0, 0); + rectGraphic.lineTo(-d, 0); + rectGraphic.lineTo(-d, -d); + rectGraphic.lineTo(-d * 3, -d); + rectGraphic.moveTo(-d, 0); + rectGraphic.lineTo(-d, d); + rectGraphic.lineTo(-d * 3, d); + } + } +} + +export class SeparatorTemplate extends JlGraphicTemplate { + constructor(dataTemplate: ISeparatorData) { + super(Separator.Type, { + dataTemplate, + }); + } + new(): Separator { + return new Separator(); + } +} diff --git a/src/graphics/separator/SeparatorDrawAssistant.ts b/src/graphics/separator/SeparatorDrawAssistant.ts new file mode 100644 index 0000000..a315d21 --- /dev/null +++ b/src/graphics/separator/SeparatorDrawAssistant.ts @@ -0,0 +1,227 @@ +import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js'; +import { + GraphicDrawAssistant, + GraphicIdGenerator, + GraphicInteractionPlugin, + GraphicRelation, + GraphicRelationParam, + GraphicStore, + JlDrawApp, + JlGraphic, + distance2, + linePoint, +} from 'src/jl-graphic'; +import { Section } from '../section/Section'; +import { + ISeparatorData, + Separator, + SeparatorConsts, + SeparatorTemplate, + separatorTypeEnum, +} from './Separator'; +import { SeparatorData } from 'src/drawApp/graphics/SeparatorInteraction'; +import { Turnout } from '../turnout/Turnout'; + +export class SeparatorDraw extends GraphicDrawAssistant< + SeparatorTemplate, + ISeparatorData +> { + SeparatorGraph: Separator; + constructor(app: JlDrawApp, template: SeparatorTemplate) { + super(app, template, 'sym_o_square', '不展示1'); + this.SeparatorGraph = this.graphicTemplate.new(); + this.container.addChild(this.SeparatorGraph); + SeparatorInteraction.init(app); + } + + bind(): void { + super.bind(); + this.SeparatorGraph.loadData(this.graphicTemplate.datas); + this.SeparatorGraph.doRepaint(); + } + + onLeftDown(e: FederatedPointerEvent): void { + this.container.position.copyFrom(this.toCanvasCoordinates(e.global)); + this.createAndStore(true); + } + + redraw(p: Point): void { + this.container.position.copyFrom(p); + } + + prepareData(data: ISeparatorData): boolean { + data.transform = this.container.saveTransform(); + return true; + } + oneGenerates() { + const SeparatorAll = this.app.queryStore.queryByType( + Separator.Type + ); + this.app.deleteGraphics(...SeparatorAll); + const rMap = new Map(); + const sections = this.app.queryStore.queryByType
(Section.Type); + const turnouts = this.app.queryStore.queryByType(Turnout.Type); + function setKey(gr: GraphicRelationParam): string { + let key = ''; + key = `${gr.g.id}_${gr.param}`; + return key; + } + sections.forEach((section) => { + const allR = section.relationManage.getRelationsOfGraphic(section); + const port: string[] = []; + allR.forEach((relation, index) => { + const r = relation.getRelationParam(section); + port.push(r.param); + const other = relation.getOtherRelationParam(section); + if (!rMap.has(setKey(r))) { + rMap.set(setKey(r), { ...r }); + } + if (!rMap.has(setKey(other))) { + rMap.set(setKey(other), { ...other, repetition: true }); + } + if (index == allR.length - 1) { + if (!port.includes('A')) { + rMap.set(`${section.id}_A`, { + g: section, + param: 'A', + separatorType: separatorTypeEnum.endA, + }); + } + if (!port.includes('B')) { + rMap.set(`${section.id}_B`, { + g: section, + param: 'B', + separatorType: separatorTypeEnum.endB, + }); + } + } + }); + }); + turnouts.forEach((turnout) => { + const allR = turnout.relationManage.getRelationsOfGraphic(turnout); + const port: string[] = []; + allR.forEach((relation, index) => { + const r = relation.getRelationParam(turnout); + port.push(r.param); + const other = relation.getOtherRelationParam(turnout); + if (!rMap.has(setKey(r)) && r.param == 'C') { + rMap.set(setKey(r), { + ...r, + separatorType: separatorTypeEnum.turnout, + }); + } + if (!rMap.has(setKey(other)) && other.param == 'C') { + rMap.set(setKey(other), { + ...other, + separatorType: separatorTypeEnum.turnout, + repetition: true, + }); + } + if (index == allR.length - 1) { + if (!port.includes('A')) { + rMap.set(`${turnout.id}_A`, { + g: turnout, + param: 'A', + separatorType: separatorTypeEnum.endB, + }); + } + if (!port.includes('B')) { + rMap.set(`${turnout.id}_B`, { + g: turnout, + param: 'B', + separatorType: separatorTypeEnum.endA, + }); + } + } + }); + }); + rMap.forEach((item) => { + if (!item.repetition) { + const sType = item.separatorType || separatorTypeEnum.section; + const separator = new Separator(); + const data = new SeparatorData(); + data.separatorType = sType; + separator.loadData(data); + let p; + if (item.g.type == Section.Type) { + p = item.g.getStartPoint(); + if (item.param == 'B') { + p = item.g.getEndPoint(); + } + } else if (item.g.type == Turnout.Type) { + const ps = item.g.getPortPoints(); + let l = 2; + if (item.param == 'A') { + l = 0; + } else if (item.param == 'B') { + l = 1; + } + p = ps[l][0]; + } + const tps = item.g.localToCanvasPoint(p); + separator.position.set(tps.x, tps.y); + separator.id = GraphicIdGenerator.next(); + this.storeGraphic(separator); + } + }); + } +} + +//碰撞检测 +export class SeparatorGraphicHitArea implements IHitArea { + separator: Separator; + constructor(separator: Separator) { + this.separator = separator; + } + contains(x: number, y: number): boolean { + let contains = false; + const endTypeArr = ['endA', 'endB']; + let d = SeparatorConsts.radius; + if (endTypeArr.includes(this.separator.datas.separatorType)) { + if (this.separator.datas.separatorType == 'endB') { + d = -d; + } + const tolerance = SeparatorConsts.lineWidth; + const p1 = new Point(0, 0); + const p2 = new Point(-d, 0); + const p3 = new Point(-d, -d); + const p4 = new Point(-d * 3, -d); + const p5 = new Point(-d, d); + const p6 = new Point(-d * 3, d); + const p = new Point(x, y); + contains = contains || linePoint(p1, p2, p, tolerance); + contains = contains || linePoint(p2, p3, p, tolerance); + contains = contains || linePoint(p3, p4, p, tolerance); + contains = contains || linePoint(p2, p5, p, tolerance); + contains = contains || linePoint(p5, p6, p, tolerance); + } + return contains; + } +} + +export class SeparatorInteraction extends GraphicInteractionPlugin { + static Name = 'Separator_transform'; + constructor(app: JlDrawApp) { + super(SeparatorInteraction.Name, app); + } + static init(app: JlDrawApp) { + return new SeparatorInteraction(app); + } + filter(...grahpics: JlGraphic[]): Separator[] | undefined { + return grahpics + .filter((g) => g.type === Separator.Type) + .map((g) => g as Separator); + } + bind(g: Separator): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + g.rectGraphic.hitArea = new SeparatorGraphicHitArea(g); + } + unbind(g: Separator): void { + g.eventMode = 'none'; + g.scalable = false; + g.rotatable = false; + } +} diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index 16ee051..c850163 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -178,6 +178,8 @@ import { errorNotify, successNotify } from 'src/utils/CommonNotify'; import { saveAsDraft } from 'src/api/DraftApi'; import { ApiError } from 'src/boot/axios'; import { OneClickGenerate } from 'src/graphics/trainWindow/oneClickDrawAssistant'; +import { Separator } from 'src/graphics/separator/Separator'; +import { SeparatorDraw } from 'src/graphics/separator/SeparatorDrawAssistant'; const route = useRoute(); const router = useRouter(); @@ -303,6 +305,10 @@ function buildRelations() { } function oneClickGeneration() { + const separatorDraw = drawStore + .getDrawApp() + .getDrawAssistant(Separator.Type) as SeparatorDraw; + separatorDraw.oneGenerates(); drawStore.getDrawApp().interactionPlugin(OneClickGenerate.Type).resume(); } diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index e72c60c..da66860 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -25,9 +25,10 @@ export namespace graphicData { polygons?: Polygon[]; trainWindows?: TrainWindow[]; axleCountings?: AxleCounting[]; + separators?: Separator[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; @@ -80,6 +81,9 @@ export namespace graphicData { if ("axleCountings" in data && data.axleCountings != undefined) { this.axleCountings = data.axleCountings; } + if ("separators" in data && data.separators != undefined) { + this.separators = data.separators; + } } } get canvas() { @@ -187,6 +191,12 @@ export namespace graphicData { set axleCountings(value: AxleCounting[]) { pb_1.Message.setRepeatedWrapperField(this, 17, value); } + get separators() { + return pb_1.Message.getRepeatedWrapperField(this, Separator, 18) as Separator[]; + } + set separators(value: Separator[]) { + pb_1.Message.setRepeatedWrapperField(this, 18, value); + } static fromObject(data: { canvas?: ReturnType; links?: ReturnType[]; @@ -205,6 +215,7 @@ export namespace graphicData { polygons?: ReturnType[]; trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; + separators?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -258,6 +269,9 @@ export namespace graphicData { if (data.axleCountings != null) { message.axleCountings = data.axleCountings.map(item => AxleCounting.fromObject(item)); } + if (data.separators != null) { + message.separators = data.separators.map(item => Separator.fromObject(item)); + } return message; } toObject() { @@ -279,6 +293,7 @@ export namespace graphicData { polygons?: ReturnType[]; trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; + separators?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -331,6 +346,9 @@ export namespace graphicData { if (this.axleCountings != null) { data.axleCountings = this.axleCountings.map((item: AxleCounting) => item.toObject()); } + if (this.separators != null) { + data.separators = this.separators.map((item: Separator) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -371,6 +389,8 @@ export namespace graphicData { writer.writeRepeatedMessage(16, this.trainWindows, (item: TrainWindow) => item.serialize(writer)); if (this.axleCountings.length) writer.writeRepeatedMessage(17, this.axleCountings, (item: AxleCounting) => item.serialize(writer)); + if (this.separators.length) + writer.writeRepeatedMessage(18, this.separators, (item: Separator) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -431,6 +451,9 @@ export namespace graphicData { case 17: reader.readMessage(message.axleCountings, () => pb_1.Message.addToRepeatedWrapperField(message, 17, AxleCounting.deserialize(reader), AxleCounting)); break; + case 18: + reader.readMessage(message.separators, () => pb_1.Message.addToRepeatedWrapperField(message, 18, Separator.deserialize(reader), Separator)); + break; default: reader.skipField(); } } @@ -3955,4 +3978,120 @@ export namespace graphicData { C = 2 } } + export class Separator extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + common?: CommonInfo; + code?: string; + separatorType?: string; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("common" in data && data.common != undefined) { + this.common = data.common; + } + if ("code" in data && data.code != undefined) { + this.code = data.code; + } + if ("separatorType" in data && data.separatorType != undefined) { + this.separatorType = data.separatorType; + } + } + } + get common() { + return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; + } + set common(value: CommonInfo) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_common() { + return pb_1.Message.getField(this, 1) != null; + } + get code() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set code(value: string) { + pb_1.Message.setField(this, 2, value); + } + get separatorType() { + return pb_1.Message.getFieldWithDefault(this, 3, "") as string; + } + set separatorType(value: string) { + pb_1.Message.setField(this, 3, value); + } + static fromObject(data: { + common?: ReturnType; + code?: string; + separatorType?: string; + }): Separator { + const message = new Separator({}); + if (data.common != null) { + message.common = CommonInfo.fromObject(data.common); + } + if (data.code != null) { + message.code = data.code; + } + if (data.separatorType != null) { + message.separatorType = data.separatorType; + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + separatorType?: string; + } = {}; + if (this.common != null) { + data.common = this.common.toObject(); + } + if (this.code != null) { + data.code = this.code; + } + if (this.separatorType != null) { + data.separatorType = this.separatorType; + } + 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.has_common) + writer.writeMessage(1, this.common, () => this.common.serialize(writer)); + if (this.code.length) + writer.writeString(2, this.code); + if (this.separatorType.length) + writer.writeString(3, this.separatorType); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Separator { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Separator(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); + break; + case 2: + message.code = reader.readString(); + break; + case 3: + message.separatorType = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Separator { + return Separator.deserialize(bytes); + } + } }