继电器处理数据

This commit is contained in:
joylink_zhaoerwei 2023-12-13 10:22:24 +08:00
parent 9660338669
commit dff4cf833b
2 changed files with 88 additions and 2 deletions

View File

@ -235,6 +235,23 @@ export function saveDrawDatas(app: IDrawApp) {
storage.UniqueIdPrefix = UniqueIdPrefix;
storage.ciCjList = ciCjList;
storage.ciQdList = ciQdList;
storage.deviceRelateRelayList.forEach((item) => {
item.combinationtypes.forEach((itemB) => {
itemB.newrefRelays = itemB.refRelays.map((item) => +item);
});
});
storage.ciCjList.cjList.forEach((item) => {
item.bitList.forEach((item) => {
item.refRelays.forEach((itemB) => {
itemB.newrelayId = +itemB.relayId;
});
});
});
storage.ciQdList.qdList.forEach((item) => {
item.bitList.forEach((itemB) => {
itemB.newrefRelays = itemB.refRelays.map((item) => +item);
});
});
const base64 = fromUint8Array(storage.serialize());
console.log('保存数据', storage);
return base64;

View File

@ -795,9 +795,10 @@ export namespace relayCabinetGraphicData {
constructor(data?: any[] | {
code?: string;
refRelays?: string[];
newrefRelays?: number[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], this.#one_of_decls);
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("code" in data && data.code != undefined) {
this.code = data.code;
@ -805,6 +806,9 @@ export namespace relayCabinetGraphicData {
if ("refRelays" in data && data.refRelays != undefined) {
this.refRelays = data.refRelays;
}
if ("newrefRelays" in data && data.newrefRelays != undefined) {
this.newrefRelays = data.newrefRelays;
}
}
}
get code() {
@ -819,9 +823,16 @@ export namespace relayCabinetGraphicData {
set refRelays(value: string[]) {
pb_1.Message.setField(this, 2, value);
}
get newrefRelays() {
return pb_1.Message.getFieldWithDefault(this, 3, []) as number[];
}
set newrefRelays(value: number[]) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
code?: string;
refRelays?: string[];
newrefRelays?: number[];
}): Combinationtype {
const message = new Combinationtype({});
if (data.code != null) {
@ -830,12 +841,16 @@ export namespace relayCabinetGraphicData {
if (data.refRelays != null) {
message.refRelays = data.refRelays;
}
if (data.newrefRelays != null) {
message.newrefRelays = data.newrefRelays;
}
return message;
}
toObject() {
const data: {
code?: string;
refRelays?: string[];
newrefRelays?: number[];
} = {};
if (this.code != null) {
data.code = this.code;
@ -843,6 +858,9 @@ export namespace relayCabinetGraphicData {
if (this.refRelays != null) {
data.refRelays = this.refRelays;
}
if (this.newrefRelays != null) {
data.newrefRelays = this.newrefRelays;
}
return data;
}
serialize(): Uint8Array;
@ -853,6 +871,8 @@ export namespace relayCabinetGraphicData {
writer.writeString(1, this.code);
if (this.refRelays.length)
writer.writeRepeatedString(2, this.refRelays);
if (this.newrefRelays.length)
writer.writePackedUint32(3, this.newrefRelays);
if (!w)
return writer.getResultBuffer();
}
@ -868,6 +888,9 @@ export namespace relayCabinetGraphicData {
case 2:
pb_1.Message.addToRepeatedField(message, 2, reader.readString());
break;
case 3:
message.newrefRelays = reader.readPackedUint32();
break;
default: reader.skipField();
}
}
@ -1245,6 +1268,7 @@ export namespace relayCabinetGraphicData {
constructor(data?: any[] | {
relayId?: string;
position?: CjDataItem.PostionType;
newrelayId?: number;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -1255,6 +1279,9 @@ export namespace relayCabinetGraphicData {
if ("position" in data && data.position != undefined) {
this.position = data.position;
}
if ("newrelayId" in data && data.newrelayId != undefined) {
this.newrelayId = data.newrelayId;
}
}
}
get relayId() {
@ -1269,9 +1296,16 @@ export namespace relayCabinetGraphicData {
set position(value: CjDataItem.PostionType) {
pb_1.Message.setField(this, 2, value);
}
get newrelayId() {
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
}
set newrelayId(value: number) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
relayId?: string;
position?: CjDataItem.PostionType;
newrelayId?: number;
}): CjDataItem {
const message = new CjDataItem({});
if (data.relayId != null) {
@ -1280,12 +1314,16 @@ export namespace relayCabinetGraphicData {
if (data.position != null) {
message.position = data.position;
}
if (data.newrelayId != null) {
message.newrelayId = data.newrelayId;
}
return message;
}
toObject() {
const data: {
relayId?: string;
position?: CjDataItem.PostionType;
newrelayId?: number;
} = {};
if (this.relayId != null) {
data.relayId = this.relayId;
@ -1293,6 +1331,9 @@ export namespace relayCabinetGraphicData {
if (this.position != null) {
data.position = this.position;
}
if (this.newrelayId != null) {
data.newrelayId = this.newrelayId;
}
return data;
}
serialize(): Uint8Array;
@ -1303,6 +1344,8 @@ export namespace relayCabinetGraphicData {
writer.writeString(1, this.relayId);
if (this.position != CjDataItem.PostionType.Q)
writer.writeEnum(2, this.position);
if (this.newrelayId != 0)
writer.writeUint32(3, this.newrelayId);
if (!w)
return writer.getResultBuffer();
}
@ -1318,6 +1361,9 @@ export namespace relayCabinetGraphicData {
case 2:
message.position = reader.readEnum();
break;
case 3:
message.newrelayId = reader.readUint32();
break;
default: reader.skipField();
}
}
@ -1520,13 +1566,17 @@ export namespace relayCabinetGraphicData {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
refRelays?: string[];
newrefRelays?: number[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], this.#one_of_decls);
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("refRelays" in data && data.refRelays != undefined) {
this.refRelays = data.refRelays;
}
if ("newrefRelays" in data && data.newrefRelays != undefined) {
this.newrefRelays = data.newrefRelays;
}
}
}
get refRelays() {
@ -1535,22 +1585,36 @@ export namespace relayCabinetGraphicData {
set refRelays(value: string[]) {
pb_1.Message.setField(this, 1, value);
}
get newrefRelays() {
return pb_1.Message.getFieldWithDefault(this, 2, []) as number[];
}
set newrefRelays(value: number[]) {
pb_1.Message.setField(this, 2, value);
}
static fromObject(data: {
refRelays?: string[];
newrefRelays?: number[];
}): QdData {
const message = new QdData({});
if (data.refRelays != null) {
message.refRelays = data.refRelays;
}
if (data.newrefRelays != null) {
message.newrefRelays = data.newrefRelays;
}
return message;
}
toObject() {
const data: {
refRelays?: string[];
newrefRelays?: number[];
} = {};
if (this.refRelays != null) {
data.refRelays = this.refRelays;
}
if (this.newrefRelays != null) {
data.newrefRelays = this.newrefRelays;
}
return data;
}
serialize(): Uint8Array;
@ -1559,6 +1623,8 @@ export namespace relayCabinetGraphicData {
const writer = w || new pb_1.BinaryWriter();
if (this.refRelays.length)
writer.writeRepeatedString(1, this.refRelays);
if (this.newrefRelays.length)
writer.writePackedUint32(2, this.newrefRelays);
if (!w)
return writer.getResultBuffer();
}
@ -1571,6 +1637,9 @@ export namespace relayCabinetGraphicData {
case 1:
pb_1.Message.addToRepeatedField(message, 1, reader.readString());
break;
case 2:
message.newrefRelays = reader.readPackedUint32();
break;
default: reader.skipField();
}
}