修改继电器柜的proto

This commit is contained in:
joylink_zhaoerwei 2023-09-06 09:32:49 +08:00
parent 816b0a6824
commit 54f15a959f
5 changed files with 45 additions and 807 deletions

View File

@ -1,152 +0,0 @@
import * as pb_1 from 'google-protobuf';
import {
ChildTransform,
GraphicData,
GraphicState,
GraphicTransform,
IChildTransform,
IGraphicTransform,
} from 'src/jl-graphic';
// import { toStorageTransform } from '..';
import { graphicData } from 'src/protos/relayCabinetLayoutGraphics';
import { IPointData, Point } from 'pixi.js';
export interface ICommonInfo {
id: string;
graphicType: string;
transform: IGraphicTransform;
childTransforms: IChildTransform[];
}
export function fromStoragePoint(p: graphicData.Point): Point {
return new Point(p.x, p.y);
}
export function toStoragePoint(p: IPointData): graphicData.Point {
return new graphicData.Point({ x: p.x, y: p.y });
}
export function fromStorageTransfrom(
transfrom: graphicData.Transform
): GraphicTransform {
return new GraphicTransform(
fromStoragePoint(transfrom.position),
fromStoragePoint(transfrom.scale),
transfrom.rotation,
fromStoragePoint(transfrom.skew)
);
}
export function toStorageTransform(
transform: GraphicTransform
): graphicData.Transform {
return new graphicData.Transform({
position: toStoragePoint(transform.position),
scale: toStoragePoint(transform.scale),
rotation: transform.rotation,
skew: toStoragePoint(transform.skew),
});
}
export interface IProtoGraphicData extends pb_1.Message {
common: ICommonInfo;
code?: string;
}
export abstract class GraphicDataBase implements GraphicData {
_data: IProtoGraphicData;
constructor(data: IProtoGraphicData) {
this._data = data;
}
static defaultCommonInfo(graphicType: string): graphicData.CommonInfo {
return new graphicData.CommonInfo({
id: '',
graphicType: graphicType,
transform: new graphicData.Transform({
position: new graphicData.Point({ x: 0, y: 0 }),
scale: new graphicData.Point({ x: 1, y: 1 }),
rotation: 0,
skew: new graphicData.Point({ x: 0, y: 0 }),
}),
childTransforms: [],
});
}
getData<D extends IProtoGraphicData>(): D {
return this._data as D;
}
get id(): string {
return this._data.common.id;
}
set id(v: string) {
this._data.common.id = v;
}
get graphicType(): string {
return this._data.common.graphicType;
}
set graphicType(v: string) {
this._data.common.graphicType = v;
}
get transform(): GraphicTransform {
return GraphicTransform.from(this._data.common.transform);
}
set transform(v: GraphicTransform) {
this._data.common.transform = toStorageTransform(v);
}
get childTransforms(): ChildTransform[] | undefined {
const cts: ChildTransform[] = [];
if (this._data.common.childTransforms) {
this._data.common.childTransforms.forEach((ct) => {
cts.push(ChildTransform.from(ct));
});
}
return cts;
}
set childTransforms(v: ChildTransform[] | undefined) {
if (v) {
const cts: graphicData.ChildTransform[] = [];
v.forEach((ct) =>
cts.push(
new graphicData.ChildTransform({
...ct,
transform: toStorageTransform(ct.transform),
})
)
);
this._data.common.childTransforms = cts;
} else {
this._data.common.childTransforms = [];
}
}
clone(): GraphicData {
throw new Error('Method not implemented.');
}
copyFrom(gd: GraphicDataBase): void {
pb_1.Message.copyInto(gd._data, this._data);
}
eq(other: GraphicDataBase): boolean {
return pb_1.Message.equals(this._data, other._data);
}
}
export abstract class GraphicStateBase implements GraphicState {
_graphicType: string;
_state: pb_1.Message;
constructor(state: pb_1.Message, graphicType: string) {
this._state = state;
this._graphicType = graphicType;
}
abstract get code(): string;
abstract copyFrom(data: GraphicState): void;
abstract eq(data: GraphicState): boolean;
getState<S extends pb_1.Message>(): S {
return this._state as S;
}
get graphicType(): string {
return this._graphicType;
}
clone(): GraphicState {
throw new Error('Method not implemented.');
}
}

View File

@ -3,17 +3,17 @@ import {
IRelayCabinetData, IRelayCabinetData,
RelayCabinet, RelayCabinet,
} from 'src/graphics/relayCabinet/RelayCabinet'; } from 'src/graphics/relayCabinet/RelayCabinet';
import { graphicData } from 'src/protos/relayCabinetLayoutGraphics'; import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics';
import { GraphicDataBase } from './GraphicDataBase'; import { GraphicDataBase } from '../graphics/GraphicDataBase';
export class RelayCabinetData export class RelayCabinetData
extends GraphicDataBase extends GraphicDataBase
implements IRelayCabinetData implements IRelayCabinetData
{ {
constructor(data?: graphicData.RelayCabinet) { constructor(data?: relayCabinetGraphicData.RelayCabinet) {
let relayCabinet; let relayCabinet;
if (!data) { if (!data) {
relayCabinet = new graphicData.RelayCabinet({ relayCabinet = new relayCabinetGraphicData.RelayCabinet({
common: GraphicDataBase.defaultCommonInfo(RelayCabinet.Type), common: GraphicDataBase.defaultCommonInfo(RelayCabinet.Type),
}); });
} else { } else {
@ -22,8 +22,8 @@ export class RelayCabinetData
super(relayCabinet); super(relayCabinet);
} }
public get data(): graphicData.RelayCabinet { public get data(): relayCabinetGraphicData.RelayCabinet {
return this.getData<graphicData.RelayCabinet>(); return this.getData<relayCabinetGraphicData.RelayCabinet>();
} }
get code(): string { get code(): string {

View File

@ -1,19 +1,13 @@
import * as pb_1 from 'google-protobuf'; import * as pb_1 from 'google-protobuf';
import { import { IRelayData, Relay } from 'src/graphics/relay/Relay';
IRelayData, import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics';
Relay, import { GraphicDataBase } from '../graphics/GraphicDataBase';
} from 'src/graphics/relay/Relay';
import { graphicData } from 'src/protos/relayCabinetLayoutGraphics';
import { GraphicDataBase } from './GraphicDataBase';
export class RelayData export class RelayData extends GraphicDataBase implements IRelayData {
extends GraphicDataBase constructor(data?: relayCabinetGraphicData.Relay) {
implements IRelayData
{
constructor(data?: graphicData.Relay) {
let relay; let relay;
if (!data) { if (!data) {
relay = new graphicData.Relay({ relay = new relayCabinetGraphicData.Relay({
common: GraphicDataBase.defaultCommonInfo(Relay.Type), common: GraphicDataBase.defaultCommonInfo(Relay.Type),
}); });
} else { } else {
@ -22,8 +16,8 @@ export class RelayData
super(relay); super(relay);
} }
public get data(): graphicData.Relay { public get data(): relayCabinetGraphicData.Relay {
return this.getData<graphicData.Relay>(); return this.getData<relayCabinetGraphicData.Relay>();
} }
get code(): string { get code(): string {

View File

@ -15,8 +15,9 @@ import { Dialog } from 'quasar';
import { saveDraft, getDraft } from 'src/api/DraftApi'; import { saveDraft, getDraft } from 'src/api/DraftApi';
import { checkMapData } from 'src/api/Simulation'; import { checkMapData } from 'src/api/Simulation';
import { useRelayCabinetStore } from 'src/stores/relayCabinet-store'; import { useRelayCabinetStore } from 'src/stores/relayCabinet-store';
import { graphicData } from 'src/protos/relayCabinetLayoutGraphics'; import { graphicData } from 'src/protos/stationLayoutGraphics';
import { toStorageTransform } from './relayCabinetGraphics/GraphicDataBase'; import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics';
import { toStorageTransform } from './graphics/GraphicDataBase';
import { import {
RelayCabinet, RelayCabinet,
RelayCabinetTemplate, RelayCabinetTemplate,
@ -144,9 +145,8 @@ export function saveDrawToServer(app: IDrawApp) {
}); });
} }
// const StorageKey = 'graphic-storage';
export function saveDrawDatas(app: IDrawApp) { export function saveDrawDatas(app: IDrawApp) {
const storage = new graphicData.RelayCabinetGraphicStorage(); const storage = new relayCabinetGraphicData.RelayCabinetGraphicStorage();
const canvasData = app.canvas.saveData(); const canvasData = app.canvas.saveData();
storage.canvas = new graphicData.Canvas({ storage.canvas = new graphicData.Canvas({
...canvasData, ...canvasData,
@ -178,9 +178,10 @@ export async function loadDrawDatas(): Promise<IGraphicStorage> {
} }
const { proto: base64 } = await getDraft(id); const { proto: base64 } = await getDraft(id);
if (base64) { if (base64) {
const storage = graphicData.RelayCabinetGraphicStorage.deserialize( const storage =
toUint8Array(base64) relayCabinetGraphicData.RelayCabinetGraphicStorage.deserialize(
); toUint8Array(base64)
);
const datas: GraphicData[] = []; const datas: GraphicData[] = [];
storage.relayCabinets.forEach((relayCabinet) => { storage.relayCabinets.forEach((relayCabinet) => {
datas.push(new RelayCabinetData(relayCabinet)); datas.push(new RelayCabinetData(relayCabinet));

View File

@ -3,12 +3,13 @@
* compiler version: 4.23.1 * compiler version: 4.23.1
* source: relayCabinetLayoutGraphics.proto * source: relayCabinetLayoutGraphics.proto
* git: https://github.com/thesayyn/protoc-gen-ts */ * git: https://github.com/thesayyn/protoc-gen-ts */
import * as dependency_1 from "./stationLayoutGraphics";
import * as pb_1 from "google-protobuf"; import * as pb_1 from "google-protobuf";
export namespace graphicData { export namespace relayCabinetGraphicData {
export class RelayCabinetGraphicStorage extends pb_1.Message { export class RelayCabinetGraphicStorage extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | { constructor(data?: any[] | {
canvas?: Canvas; canvas?: dependency_1.graphicData.Canvas;
relayCabinets?: RelayCabinet[]; relayCabinets?: RelayCabinet[];
relays?: Relay[]; relays?: Relay[];
}) { }) {
@ -27,9 +28,9 @@ export namespace graphicData {
} }
} }
get canvas() { get canvas() {
return pb_1.Message.getWrapperField(this, Canvas, 1) as Canvas; return pb_1.Message.getWrapperField(this, dependency_1.graphicData.Canvas, 1) as dependency_1.graphicData.Canvas;
} }
set canvas(value: Canvas) { set canvas(value: dependency_1.graphicData.Canvas) {
pb_1.Message.setWrapperField(this, 1, value); pb_1.Message.setWrapperField(this, 1, value);
} }
get has_canvas() { get has_canvas() {
@ -48,13 +49,13 @@ export namespace graphicData {
pb_1.Message.setRepeatedWrapperField(this, 3, value); pb_1.Message.setRepeatedWrapperField(this, 3, value);
} }
static fromObject(data: { static fromObject(data: {
canvas?: ReturnType<typeof Canvas.prototype.toObject>; canvas?: ReturnType<typeof dependency_1.graphicData.Canvas.prototype.toObject>;
relayCabinets?: ReturnType<typeof RelayCabinet.prototype.toObject>[]; relayCabinets?: ReturnType<typeof RelayCabinet.prototype.toObject>[];
relays?: ReturnType<typeof Relay.prototype.toObject>[]; relays?: ReturnType<typeof Relay.prototype.toObject>[];
}): RelayCabinetGraphicStorage { }): RelayCabinetGraphicStorage {
const message = new RelayCabinetGraphicStorage({}); const message = new RelayCabinetGraphicStorage({});
if (data.canvas != null) { if (data.canvas != null) {
message.canvas = Canvas.fromObject(data.canvas); message.canvas = dependency_1.graphicData.Canvas.fromObject(data.canvas);
} }
if (data.relayCabinets != null) { if (data.relayCabinets != null) {
message.relayCabinets = data.relayCabinets.map(item => RelayCabinet.fromObject(item)); message.relayCabinets = data.relayCabinets.map(item => RelayCabinet.fromObject(item));
@ -66,7 +67,7 @@ export namespace graphicData {
} }
toObject() { toObject() {
const data: { const data: {
canvas?: ReturnType<typeof Canvas.prototype.toObject>; canvas?: ReturnType<typeof dependency_1.graphicData.Canvas.prototype.toObject>;
relayCabinets?: ReturnType<typeof RelayCabinet.prototype.toObject>[]; relayCabinets?: ReturnType<typeof RelayCabinet.prototype.toObject>[];
relays?: ReturnType<typeof Relay.prototype.toObject>[]; relays?: ReturnType<typeof Relay.prototype.toObject>[];
} = {}; } = {};
@ -101,7 +102,7 @@ export namespace graphicData {
break; break;
switch (reader.getFieldNumber()) { switch (reader.getFieldNumber()) {
case 1: case 1:
reader.readMessage(message.canvas, () => message.canvas = Canvas.deserialize(reader)); reader.readMessage(message.canvas, () => message.canvas = dependency_1.graphicData.Canvas.deserialize(reader));
break; break;
case 2: case 2:
reader.readMessage(message.relayCabinets, () => pb_1.Message.addToRepeatedWrapperField(message, 2, RelayCabinet.deserialize(reader), RelayCabinet)); reader.readMessage(message.relayCabinets, () => pb_1.Message.addToRepeatedWrapperField(message, 2, RelayCabinet.deserialize(reader), RelayCabinet));
@ -121,616 +122,10 @@ export namespace graphicData {
return RelayCabinetGraphicStorage.deserialize(bytes); return RelayCabinetGraphicStorage.deserialize(bytes);
} }
} }
export class Canvas extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
width?: number;
height?: number;
backgroundColor?: string;
viewportTransform?: Transform;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("width" in data && data.width != undefined) {
this.width = data.width;
}
if ("height" in data && data.height != undefined) {
this.height = data.height;
}
if ("backgroundColor" in data && data.backgroundColor != undefined) {
this.backgroundColor = data.backgroundColor;
}
if ("viewportTransform" in data && data.viewportTransform != undefined) {
this.viewportTransform = data.viewportTransform;
}
}
}
get width() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number;
}
set width(value: number) {
pb_1.Message.setField(this, 1, value);
}
get height() {
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
}
set height(value: number) {
pb_1.Message.setField(this, 2, value);
}
get backgroundColor() {
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
}
set backgroundColor(value: string) {
pb_1.Message.setField(this, 3, value);
}
get viewportTransform() {
return pb_1.Message.getWrapperField(this, Transform, 4) as Transform;
}
set viewportTransform(value: Transform) {
pb_1.Message.setWrapperField(this, 4, value);
}
get has_viewportTransform() {
return pb_1.Message.getField(this, 4) != null;
}
static fromObject(data: {
width?: number;
height?: number;
backgroundColor?: string;
viewportTransform?: ReturnType<typeof Transform.prototype.toObject>;
}): Canvas {
const message = new Canvas({});
if (data.width != null) {
message.width = data.width;
}
if (data.height != null) {
message.height = data.height;
}
if (data.backgroundColor != null) {
message.backgroundColor = data.backgroundColor;
}
if (data.viewportTransform != null) {
message.viewportTransform = Transform.fromObject(data.viewportTransform);
}
return message;
}
toObject() {
const data: {
width?: number;
height?: number;
backgroundColor?: string;
viewportTransform?: ReturnType<typeof Transform.prototype.toObject>;
} = {};
if (this.width != null) {
data.width = this.width;
}
if (this.height != null) {
data.height = this.height;
}
if (this.backgroundColor != null) {
data.backgroundColor = this.backgroundColor;
}
if (this.viewportTransform != null) {
data.viewportTransform = this.viewportTransform.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.width != 0)
writer.writeInt32(1, this.width);
if (this.height != 0)
writer.writeInt32(2, this.height);
if (this.backgroundColor.length)
writer.writeString(3, this.backgroundColor);
if (this.has_viewportTransform)
writer.writeMessage(4, this.viewportTransform, () => this.viewportTransform.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Canvas {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Canvas();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.width = reader.readInt32();
break;
case 2:
message.height = reader.readInt32();
break;
case 3:
message.backgroundColor = reader.readString();
break;
case 4:
reader.readMessage(message.viewportTransform, () => message.viewportTransform = Transform.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Canvas {
return Canvas.deserialize(bytes);
}
}
export class Point extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
x?: number;
y?: number;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("x" in data && data.x != undefined) {
this.x = data.x;
}
if ("y" in data && data.y != undefined) {
this.y = data.y;
}
}
}
get x() {
return pb_1.Message.getFieldWithDefault(this, 1, 0) as number;
}
set x(value: number) {
pb_1.Message.setField(this, 1, value);
}
get y() {
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
}
set y(value: number) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
x?: number;
y?: number;
}): Point {
const message = new Point({});
if (data.x != null) {
message.x = data.x;
}
if (data.y != null) {
message.y = data.y;
}
return message;
}
toObject() {
const data: {
x?: number;
y?: number;
} = {};
if (this.x != null) {
data.x = this.x;
}
if (this.y != null) {
data.y = this.y;
}
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.x != 0)
writer.writeFloat(1, this.x);
if (this.y != 0)
writer.writeFloat(2, this.y);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Point {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Point();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.x = reader.readFloat();
break;
case 2:
message.y = reader.readFloat();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Point {
return Point.deserialize(bytes);
}
}
export class Transform extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
position?: Point;
scale?: Point;
rotation?: number;
skew?: Point;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("position" in data && data.position != undefined) {
this.position = data.position;
}
if ("scale" in data && data.scale != undefined) {
this.scale = data.scale;
}
if ("rotation" in data && data.rotation != undefined) {
this.rotation = data.rotation;
}
if ("skew" in data && data.skew != undefined) {
this.skew = data.skew;
}
}
}
get position() {
return pb_1.Message.getWrapperField(this, Point, 1) as Point;
}
set position(value: Point) {
pb_1.Message.setWrapperField(this, 1, value);
}
get has_position() {
return pb_1.Message.getField(this, 1) != null;
}
get scale() {
return pb_1.Message.getWrapperField(this, Point, 2) as Point;
}
set scale(value: Point) {
pb_1.Message.setWrapperField(this, 2, value);
}
get has_scale() {
return pb_1.Message.getField(this, 2) != null;
}
get rotation() {
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
}
set rotation(value: number) {
pb_1.Message.setField(this, 3, value);
}
get skew() {
return pb_1.Message.getWrapperField(this, Point, 4) as Point;
}
set skew(value: Point) {
pb_1.Message.setWrapperField(this, 4, value);
}
get has_skew() {
return pb_1.Message.getField(this, 4) != null;
}
static fromObject(data: {
position?: ReturnType<typeof Point.prototype.toObject>;
scale?: ReturnType<typeof Point.prototype.toObject>;
rotation?: number;
skew?: ReturnType<typeof Point.prototype.toObject>;
}): Transform {
const message = new Transform({});
if (data.position != null) {
message.position = Point.fromObject(data.position);
}
if (data.scale != null) {
message.scale = Point.fromObject(data.scale);
}
if (data.rotation != null) {
message.rotation = data.rotation;
}
if (data.skew != null) {
message.skew = Point.fromObject(data.skew);
}
return message;
}
toObject() {
const data: {
position?: ReturnType<typeof Point.prototype.toObject>;
scale?: ReturnType<typeof Point.prototype.toObject>;
rotation?: number;
skew?: ReturnType<typeof Point.prototype.toObject>;
} = {};
if (this.position != null) {
data.position = this.position.toObject();
}
if (this.scale != null) {
data.scale = this.scale.toObject();
}
if (this.rotation != null) {
data.rotation = this.rotation;
}
if (this.skew != null) {
data.skew = this.skew.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.has_position)
writer.writeMessage(1, this.position, () => this.position.serialize(writer));
if (this.has_scale)
writer.writeMessage(2, this.scale, () => this.scale.serialize(writer));
if (this.rotation != 0)
writer.writeFloat(3, this.rotation);
if (this.has_skew)
writer.writeMessage(4, this.skew, () => this.skew.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Transform {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Transform();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.position, () => message.position = Point.deserialize(reader));
break;
case 2:
reader.readMessage(message.scale, () => message.scale = Point.deserialize(reader));
break;
case 3:
message.rotation = reader.readFloat();
break;
case 4:
reader.readMessage(message.skew, () => message.skew = Point.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Transform {
return Transform.deserialize(bytes);
}
}
export class ChildTransform extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
name?: string;
transform?: Transform;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("name" in data && data.name != undefined) {
this.name = data.name;
}
if ("transform" in data && data.transform != undefined) {
this.transform = data.transform;
}
}
}
get name() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set name(value: string) {
pb_1.Message.setField(this, 1, value);
}
get transform() {
return pb_1.Message.getWrapperField(this, Transform, 2) as Transform;
}
set transform(value: Transform) {
pb_1.Message.setWrapperField(this, 2, value);
}
get has_transform() {
return pb_1.Message.getField(this, 2) != null;
}
static fromObject(data: {
name?: string;
transform?: ReturnType<typeof Transform.prototype.toObject>;
}): ChildTransform {
const message = new ChildTransform({});
if (data.name != null) {
message.name = data.name;
}
if (data.transform != null) {
message.transform = Transform.fromObject(data.transform);
}
return message;
}
toObject() {
const data: {
name?: string;
transform?: ReturnType<typeof Transform.prototype.toObject>;
} = {};
if (this.name != null) {
data.name = this.name;
}
if (this.transform != null) {
data.transform = this.transform.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.name.length)
writer.writeString(1, this.name);
if (this.has_transform)
writer.writeMessage(2, this.transform, () => this.transform.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ChildTransform {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ChildTransform();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.name = reader.readString();
break;
case 2:
reader.readMessage(message.transform, () => message.transform = Transform.deserialize(reader));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): ChildTransform {
return ChildTransform.deserialize(bytes);
}
}
export class CommonInfo extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
id?: string;
graphicType?: string;
transform?: Transform;
childTransforms?: ChildTransform[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("id" in data && data.id != undefined) {
this.id = data.id;
}
if ("graphicType" in data && data.graphicType != undefined) {
this.graphicType = data.graphicType;
}
if ("transform" in data && data.transform != undefined) {
this.transform = data.transform;
}
if ("childTransforms" in data && data.childTransforms != undefined) {
this.childTransforms = data.childTransforms;
}
}
}
get id() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set id(value: string) {
pb_1.Message.setField(this, 1, value);
}
get graphicType() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set graphicType(value: string) {
pb_1.Message.setField(this, 2, value);
}
get transform() {
return pb_1.Message.getWrapperField(this, Transform, 3) as Transform;
}
set transform(value: Transform) {
pb_1.Message.setWrapperField(this, 3, value);
}
get has_transform() {
return pb_1.Message.getField(this, 3) != null;
}
get childTransforms() {
return pb_1.Message.getRepeatedWrapperField(this, ChildTransform, 4) as ChildTransform[];
}
set childTransforms(value: ChildTransform[]) {
pb_1.Message.setRepeatedWrapperField(this, 4, value);
}
static fromObject(data: {
id?: string;
graphicType?: string;
transform?: ReturnType<typeof Transform.prototype.toObject>;
childTransforms?: ReturnType<typeof ChildTransform.prototype.toObject>[];
}): CommonInfo {
const message = new CommonInfo({});
if (data.id != null) {
message.id = data.id;
}
if (data.graphicType != null) {
message.graphicType = data.graphicType;
}
if (data.transform != null) {
message.transform = Transform.fromObject(data.transform);
}
if (data.childTransforms != null) {
message.childTransforms = data.childTransforms.map(item => ChildTransform.fromObject(item));
}
return message;
}
toObject() {
const data: {
id?: string;
graphicType?: string;
transform?: ReturnType<typeof Transform.prototype.toObject>;
childTransforms?: ReturnType<typeof ChildTransform.prototype.toObject>[];
} = {};
if (this.id != null) {
data.id = this.id;
}
if (this.graphicType != null) {
data.graphicType = this.graphicType;
}
if (this.transform != null) {
data.transform = this.transform.toObject();
}
if (this.childTransforms != null) {
data.childTransforms = this.childTransforms.map((item: ChildTransform) => item.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.id.length)
writer.writeString(1, this.id);
if (this.graphicType.length)
writer.writeString(2, this.graphicType);
if (this.has_transform)
writer.writeMessage(3, this.transform, () => this.transform.serialize(writer));
if (this.childTransforms.length)
writer.writeRepeatedMessage(4, this.childTransforms, (item: ChildTransform) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CommonInfo {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CommonInfo();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.id = reader.readString();
break;
case 2:
message.graphicType = reader.readString();
break;
case 3:
reader.readMessage(message.transform, () => message.transform = Transform.deserialize(reader));
break;
case 4:
reader.readMessage(message.childTransforms, () => pb_1.Message.addToRepeatedWrapperField(message, 4, ChildTransform.deserialize(reader), ChildTransform));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CommonInfo {
return CommonInfo.deserialize(bytes);
}
}
export class RelayCabinet extends pb_1.Message { export class RelayCabinet extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | { constructor(data?: any[] | {
common?: CommonInfo; common?: dependency_1.graphicData.CommonInfo;
code?: string; code?: string;
}) { }) {
super(); super();
@ -745,9 +140,9 @@ export namespace graphicData {
} }
} }
get common() { get common() {
return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; return pb_1.Message.getWrapperField(this, dependency_1.graphicData.CommonInfo, 1) as dependency_1.graphicData.CommonInfo;
} }
set common(value: CommonInfo) { set common(value: dependency_1.graphicData.CommonInfo) {
pb_1.Message.setWrapperField(this, 1, value); pb_1.Message.setWrapperField(this, 1, value);
} }
get has_common() { get has_common() {
@ -760,12 +155,12 @@ export namespace graphicData {
pb_1.Message.setField(this, 2, value); pb_1.Message.setField(this, 2, value);
} }
static fromObject(data: { static fromObject(data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>; common?: ReturnType<typeof dependency_1.graphicData.CommonInfo.prototype.toObject>;
code?: string; code?: string;
}): RelayCabinet { }): RelayCabinet {
const message = new RelayCabinet({}); const message = new RelayCabinet({});
if (data.common != null) { if (data.common != null) {
message.common = CommonInfo.fromObject(data.common); message.common = dependency_1.graphicData.CommonInfo.fromObject(data.common);
} }
if (data.code != null) { if (data.code != null) {
message.code = data.code; message.code = data.code;
@ -774,7 +169,7 @@ export namespace graphicData {
} }
toObject() { toObject() {
const data: { const data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>; common?: ReturnType<typeof dependency_1.graphicData.CommonInfo.prototype.toObject>;
code?: string; code?: string;
} = {}; } = {};
if (this.common != null) { if (this.common != null) {
@ -803,7 +198,7 @@ export namespace graphicData {
break; break;
switch (reader.getFieldNumber()) { switch (reader.getFieldNumber()) {
case 1: case 1:
reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); reader.readMessage(message.common, () => message.common = dependency_1.graphicData.CommonInfo.deserialize(reader));
break; break;
case 2: case 2:
message.code = reader.readString(); message.code = reader.readString();
@ -823,7 +218,7 @@ export namespace graphicData {
export class Relay extends pb_1.Message { export class Relay extends pb_1.Message {
#one_of_decls: number[][] = []; #one_of_decls: number[][] = [];
constructor(data?: any[] | { constructor(data?: any[] | {
common?: CommonInfo; common?: dependency_1.graphicData.CommonInfo;
code?: string; code?: string;
}) { }) {
super(); super();
@ -838,9 +233,9 @@ export namespace graphicData {
} }
} }
get common() { get common() {
return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; return pb_1.Message.getWrapperField(this, dependency_1.graphicData.CommonInfo, 1) as dependency_1.graphicData.CommonInfo;
} }
set common(value: CommonInfo) { set common(value: dependency_1.graphicData.CommonInfo) {
pb_1.Message.setWrapperField(this, 1, value); pb_1.Message.setWrapperField(this, 1, value);
} }
get has_common() { get has_common() {
@ -853,12 +248,12 @@ export namespace graphicData {
pb_1.Message.setField(this, 2, value); pb_1.Message.setField(this, 2, value);
} }
static fromObject(data: { static fromObject(data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>; common?: ReturnType<typeof dependency_1.graphicData.CommonInfo.prototype.toObject>;
code?: string; code?: string;
}): Relay { }): Relay {
const message = new Relay({}); const message = new Relay({});
if (data.common != null) { if (data.common != null) {
message.common = CommonInfo.fromObject(data.common); message.common = dependency_1.graphicData.CommonInfo.fromObject(data.common);
} }
if (data.code != null) { if (data.code != null) {
message.code = data.code; message.code = data.code;
@ -867,7 +262,7 @@ export namespace graphicData {
} }
toObject() { toObject() {
const data: { const data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>; common?: ReturnType<typeof dependency_1.graphicData.CommonInfo.prototype.toObject>;
code?: string; code?: string;
} = {}; } = {};
if (this.common != null) { if (this.common != null) {
@ -896,7 +291,7 @@ export namespace graphicData {
break; break;
switch (reader.getFieldNumber()) { switch (reader.getFieldNumber()) {
case 1: case 1:
reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); reader.readMessage(message.common, () => message.common = dependency_1.graphicData.CommonInfo.deserialize(reader));
break; break;
case 2: case 2:
message.code = reader.readString(); message.code = reader.readString();