psl组合调整

This commit is contained in:
fan 2023-10-13 15:58:15 +08:00
parent 4152b922b4
commit a5b927cd42
5 changed files with 117 additions and 347 deletions

@ -1 +1 @@
Subproject commit 7d027a7e5e284dc2f20e3380472efad533435ace Subproject commit 73dcb43c7634f0b1ea69fd2745408f86456a56bb

View File

@ -54,28 +54,28 @@ import {
RelateDevicelistItem, RelateDevicelistItem,
} from 'src/drawApp/pslApp'; } from 'src/drawApp/pslApp';
import { usePslDrawStore } from 'src/stores/psl-draw-store'; import { usePslDrawStore } from 'src/stores/psl-draw-store';
import { PslButton } from 'src/graphics/pslButton/pslButton';
import { PslKey } from 'src/graphics/pslKey/pslKey';
import { PslLight } from 'src/graphics/pslLight/pslLight';
const pslDrawStore = usePslDrawStore(); const pslDrawStore = usePslDrawStore();
const $q = useQuasar(); const $q = useQuasar();
const tableRef = ref<QTable>(); const tableRef = ref<QTable>();
const deviceTypeMap = {
6: '车站',
};
const columns: QTable['columns'] = [ const columns: QTable['columns'] = [
{ name: 'code', label: '组合类型', field: 'code', align: 'center' },
{ {
name: 'deviceType', name: 'refRelays',
label: '设备类型', label: '关联的设备',
field: (row) => deviceTypeMap[row.deviceType as keyof typeof deviceTypeMap],
align: 'center',
},
{ name: 'code', label: '设备编号', field: 'code', align: 'center' },
{
name: 'combinationtypes',
label: '关联的组合类型',
field: (row: RelateDevicelistItem) => { field: (row: RelateDevicelistItem) => {
if (row.combinationtypes) { if (row.refDevices) {
const ref = row.combinationtypes.map( const ref = row.refDevices.map(
(combinationtype) => combinationtype.code (id) =>
(
pslDrawStore.getDrawApp().queryStore.queryById(id) as
| PslButton
| PslKey
| PslLight
).datas.code
); );
return ref.join('\\'); return ref.join('\\');
} }
@ -126,18 +126,16 @@ function creatData() {
} }
function deleteData(row: RelateDevicelistItem) { function deleteData(row: RelateDevicelistItem) {
$q.dialog({ message: `确定删除 "${row.code}" 吗?`, cancel: true }).onOk( $q.dialog({ message: '确定删除吗?', cancel: true }).onOk(async () => {
async () => { try {
try { deleteGatedRelateDevice(row);
deleteGatedRelateDevice(row); successNotify('删除数据成功!');
successNotify('删除数据成功!'); } catch (err) {
} catch (err) { errorNotify('删除失败:', err);
errorNotify('删除失败:', err); } finally {
} finally { tableRef.value?.requestServerInteraction();
tableRef.value?.requestServerInteraction();
}
} }
); });
} }
</script> </script>

View File

@ -6,80 +6,43 @@
</q-card-section> </q-card-section>
<q-separator inset></q-separator> <q-separator inset></q-separator>
<q-form ref="myForm" @submit="onSubmit" @reset="onReset"> <q-form ref="myForm" @submit="onSubmit" @reset="onReset">
<q-select
outlined
v-model="relateDeviceConfig.deviceType"
:options="optionsType"
label="设备类型"
:map-options="true"
:emit-value="true"
:rules="[(val) => val != undefined || '设备类型不能为空']"
/>
<q-input
outlined
label="设备编号"
v-model="relateDeviceConfig.code"
:rules="[(val) => val.trim() != '' || '名称不能为空']"
/>
<q-list bordered separator class="rounded-borders"> <q-list bordered separator class="rounded-borders">
<q-expansion-item <q-card>
expand-separator <q-item>
v-for="( <q-item-section no-wrap class="q-gutter-y-sm column">
combinationtype, index <q-input
) in relateDeviceConfig.combinationtypes" outlined
:key="index" v-model="relateDeviceConfig.code"
v-model="combinationtype.expanded" label="组合类型"
:label="combinationtype.code" lazy-rules
@click="toggleItem(index)" />
> <div class="q-gutter-sm row">
<q-card> <q-chip
<q-item> v-for="item in relateDeviceConfig.refDevicesCode"
<q-item-section no-wrap class="q-gutter-y-sm column"> :key="item"
<q-input square
outlined color="primary"
v-model="combinationtype.code" text-color="white"
label="组合类型" removable
lazy-rules @remove="removeSelect(item)"
>
{{ item }}
</q-chip>
</div>
<div>
<q-btn
v-show="relateDeviceConfig.refDevicesCode.length > 0"
style="width: 130px"
label="清空框选的设备"
color="red"
class="q-mr-md"
@click="clearAllSelect()"
/> />
<div class="q-gutter-sm row"> </div>
<q-chip </q-item-section>
v-for="item in combinationtype.refDevicesCode" </q-item>
:key="item" </q-card>
square
color="primary"
text-color="white"
removable
@remove="removeSelect(item)"
>
{{ item }}
</q-chip>
</div>
<div>
<q-btn
v-show="combinationtype.refDevicesCode.length > 0"
style="width: 130px"
label="清空框选的设备"
color="red"
class="q-mr-md"
@click="clearAllSelect(index)"
/>
<q-btn
label="删除组合类型"
color="secondary"
@click="deleteCombinationtype(index)"
/>
</div>
</q-item-section>
</q-item>
</q-card>
</q-expansion-item>
</q-list> </q-list>
<q-btn
class="q-mt-md"
label="增加组合类型"
color="secondary"
@click="addCombinationtype"
/>
<div class="q-gutter-sm q-pa-md row justify-center"> <div class="q-gutter-sm q-pa-md row justify-center">
<q-btn label="提交" type="submit" color="primary" class="q-mr-md" /> <q-btn label="提交" type="submit" color="primary" class="q-mr-md" />
<q-btn label="重置" type="reset" color="primary" class="q-mr-md" /> <q-btn label="重置" type="reset" color="primary" class="q-mr-md" />
@ -98,7 +61,6 @@ import { usePslDrawStore } from 'src/stores/psl-draw-store';
import { PslKey } from 'src/graphics/pslKey/pslKey'; import { PslKey } from 'src/graphics/pslKey/pslKey';
import { PslButton } from 'src/graphics/pslButton/pslButton'; import { PslButton } from 'src/graphics/pslButton/pslButton';
import { PslLight } from 'src/graphics/pslLight/pslLight'; import { PslLight } from 'src/graphics/pslLight/pslLight';
import { pslGraphicData } from 'src/protos/pslGraphics';
import { import {
creatGatedRelateDevice, creatGatedRelateDevice,
editGatedRelateDevice, editGatedRelateDevice,
@ -112,32 +74,21 @@ const pslDrawStore = usePslDrawStore();
const $q = useQuasar(); const $q = useQuasar();
const showRangeConfig = ref(true); const showRangeConfig = ref(true);
const relateDeviceConfig = ref<{ const relateDeviceConfig = ref<{
deviceType: graphicData.RelatedRef.DeviceType | undefined;
code: string; code: string;
combinationtypes: { refDevices: string[];
code: string; refDevicesCode: string[];
refDevices: string[];
refDevicesCode: string[];
expanded: boolean;
}[];
}>({ }>({
deviceType: undefined, code: '组合类型',
code: '', refDevices: [],
combinationtypes: [ refDevicesCode: [],
{ code: '组合类型', refDevices: [], refDevicesCode: [], expanded: false },
],
}); });
const handleState = ref('新建门控箱关联设备'); const handleState = ref('新建门控箱关联设备');
const optionsType = [
{ label: '车站', value: graphicData.RelatedRef.DeviceType.station },
];
let selectGraphic: JlGraphic[] = []; let selectGraphic: JlGraphic[] = [];
watch( watch(
() => pslDrawStore.selectedGraphics, () => pslDrawStore.selectedGraphics,
(val) => { (val) => {
if (val && val.length > 0 && clickIndex !== null) { if (val && val.length > 0) {
const selectFilter = pslDrawStore.selectedGraphics?.filter( const selectFilter = pslDrawStore.selectedGraphics?.filter(
(g) => (g) =>
g.type == PslKey.Type || g.type == PslKey.Type ||
@ -147,14 +98,14 @@ watch(
selectGraphic.push(...selectFilter); selectGraphic.push(...selectFilter);
selectGraphic = Array.from(new Set(selectGraphic)); selectGraphic = Array.from(new Set(selectGraphic));
pslDrawStore.getDrawApp().updateSelected(...selectGraphic); pslDrawStore.getDrawApp().updateSelected(...selectGraphic);
relateDeviceConfig.value.combinationtypes[clickIndex].refDevicesCode = relateDeviceConfig.value.refDevicesCode = selectGraphic.map((g) =>
selectGraphic.map((g) => (g as PslKey | PslButton | PslLight).datas.code == ''
(g as PslKey | PslButton | PslLight).datas.code == '' ? g.id
? g.id : (g as PslKey | PslButton | PslLight).datas.code
: (g as PslKey | PslButton | PslLight).datas.code );
); relateDeviceConfig.value.refDevices = selectGraphic.map(
relateDeviceConfig.value.combinationtypes[clickIndex].refDevices = (g) => g.id
selectGraphic.map((g) => g.id) as string[]; ) as string[];
} }
} }
); );
@ -171,28 +122,19 @@ async function onSubmit() {
myForm.value?.validate().then(async (res) => { myForm.value?.validate().then(async (res) => {
if (res) { if (res) {
try { try {
const combinationtypes: graphicData.DeviceCombinationtype[] = []; const combinationtype: graphicData.DeviceCombinationtype =
relateDeviceConfig.value.combinationtypes.forEach((combinationtype) => { new graphicData.DeviceCombinationtype({
combinationtypes.push( code: relateDeviceConfig.value.code,
new graphicData.DeviceCombinationtype({ refDevices: relateDeviceConfig.value.refDevices,
code: combinationtype.code, });
refDevices: combinationtype.refDevices,
})
);
});
const gatedRelateDevice = new pslGraphicData.GatedRelateDevice({
deviceType: relateDeviceConfig.value.deviceType,
code: relateDeviceConfig.value.code,
combinationtypes: combinationtypes,
});
if (handleState.value == '新建门控箱关联设备') { if (handleState.value == '新建门控箱关联设备') {
handle.value = '创建成功'; handle.value = '创建成功';
handleError.value = '创建失败'; handleError.value = '创建失败';
creatGatedRelateDevice(gatedRelateDevice); creatGatedRelateDevice(combinationtype);
} else { } else {
handle.value = '更新成功'; handle.value = '更新成功';
handleError.value = '更新失败'; handleError.value = '更新失败';
editGatedRelateDevice(editRow, gatedRelateDevice); editGatedRelateDevice(editRow, combinationtype);
} }
pslDrawStore.table?.requestServerInteraction(); pslDrawStore.table?.requestServerInteraction();
$q.notify({ $q.notify({
@ -221,27 +163,18 @@ async function editRelateDevices(row: RelateDevicelistItem) {
selectGraphic = []; selectGraphic = [];
drawApp.updateSelected(); drawApp.updateSelected();
editRow = row; editRow = row;
relateDeviceConfig.value.deviceType = row.deviceType; const refCode: string[] = [];
row.refDevices.forEach((id) => {
const g = drawApp.queryStore.queryById(id) as
| PslButton
| PslKey
| PslLight;
refCode.push(g.datas.code);
});
row.refDevicesCode = refCode;
relateDeviceConfig.value.code = row.code; relateDeviceConfig.value.code = row.code;
row.combinationtypes.forEach((combinationtype) => { relateDeviceConfig.value.refDevices = row.refDevices;
const refCode: string[] = []; relateDeviceConfig.value.refDevicesCode = row.refDevicesCode;
combinationtype.refDevices.forEach((id) => {
const g = drawApp.queryStore.queryById(id);
refCode.push(g.code);
});
combinationtype.refDevicesCode = refCode;
combinationtype.expanded = false;
});
relateDeviceConfig.value.combinationtypes = [];
row.combinationtypes.forEach((combinationtype) => {
const { code, refDevices, refDevicesCode, expanded } = combinationtype;
relateDeviceConfig.value.combinationtypes.push({
code,
refDevices,
refDevicesCode: refDevicesCode as string[],
expanded: expanded as boolean,
});
});
} catch (err) { } catch (err) {
$q.notify({ $q.notify({
type: 'negative', type: 'negative',
@ -250,40 +183,19 @@ async function editRelateDevices(row: RelateDevicelistItem) {
} }
} }
let clickIndex: null | number = null;
function toggleItem(index: number) {
const drawApp = pslDrawStore.getDrawApp();
selectGraphic = [];
drawApp.updateSelected();
const combinationtypes = relateDeviceConfig.value.combinationtypes;
if (combinationtypes[index].expanded == true) {
clickIndex = index;
const select: JlGraphic[] = [];
combinationtypes[index].refDevices.forEach((id: string) => {
const g = drawApp.queryStore.queryById(id);
select.push(g);
});
drawApp.updateSelected(...select);
} else {
clickIndex = null;
}
}
function removeSelect(code: string) { function removeSelect(code: string) {
const clickTarget = const removeIndex = relateDeviceConfig.value.refDevicesCode.findIndex(
relateDeviceConfig.value.combinationtypes[clickIndex as number];
const removeIndex = clickTarget.refDevicesCode.findIndex(
(item) => item == code (item) => item == code
); );
selectGraphic.splice(removeIndex, 1); selectGraphic.splice(removeIndex, 1);
clickTarget.refDevicesCode.splice(removeIndex, 1); relateDeviceConfig.value.refDevicesCode.splice(removeIndex, 1);
clickTarget.refDevices.splice(removeIndex, 1); relateDeviceConfig.value.refDevices.splice(removeIndex, 1);
pslDrawStore.getDrawApp().updateSelected(...selectGraphic); pslDrawStore.getDrawApp().updateSelected(...selectGraphic);
} }
function clearAllSelect(index: number) { function clearAllSelect() {
relateDeviceConfig.value.combinationtypes[index].refDevices = []; relateDeviceConfig.value.refDevices = [];
relateDeviceConfig.value.combinationtypes[index].refDevicesCode = []; relateDeviceConfig.value.refDevicesCode = [];
clearAllSelectAtCanvas(); clearAllSelectAtCanvas();
} }
@ -292,29 +204,12 @@ function clearAllSelectAtCanvas() {
pslDrawStore.getDrawApp().updateSelected(); pslDrawStore.getDrawApp().updateSelected();
} }
function addCombinationtype() { function onReset() {
relateDeviceConfig.value.combinationtypes.push({ handleState.value = '新建门控箱关联设备';
relateDeviceConfig.value = {
code: '组合类型', code: '组合类型',
refDevices: [], refDevices: [],
refDevicesCode: [], refDevicesCode: [],
expanded: false,
});
}
function deleteCombinationtype(index: number) {
relateDeviceConfig.value.combinationtypes.splice(index, 1);
clearAllSelectAtCanvas();
}
function onReset() {
clickIndex = null;
handleState.value = '新建门控箱关联设备';
relateDeviceConfig.value = {
deviceType: undefined,
code: '',
combinationtypes: [
{ code: '组合类型', refDevices: [], refDevicesCode: [], expanded: false },
],
}; };
clearAllSelectAtCanvas(); clearAllSelectAtCanvas();
} }

View File

@ -231,35 +231,28 @@ export async function loadPslDrawDatas(): Promise<IGraphicStorage> {
//关联设备列表的增删改查 //关联设备列表的增删改查
export interface RelateDevicelistItem { export interface RelateDevicelistItem {
deviceType: graphicData.RelatedRef.DeviceType | undefined;
code: string; code: string;
combinationtypes: { refDevices: string[];
code: string; refDevicesCode?: string[];
refDevices: string[];
refDevicesCode?: string[];
expanded?: boolean;
}[];
} }
let refDevicesList: pslGraphicData.GatedRelateDevice[] = []; let refDevicesList: graphicData.DeviceCombinationtype[] = [];
export function loadGatedRelateDeviceList() { export function loadGatedRelateDeviceList() {
return refDevicesList; return refDevicesList;
} }
export function creatGatedRelateDevice(row: pslGraphicData.GatedRelateDevice) { export function creatGatedRelateDevice(row: graphicData.DeviceCombinationtype) {
refDevicesList.push(row); refDevicesList.push(row);
console.log(refDevicesList, '====');
drawApp?.emit('postdataloaded'); drawApp?.emit('postdataloaded');
} }
export function editGatedRelateDevice( export function editGatedRelateDevice(
editRow: RelateDevicelistItem, editRow: RelateDevicelistItem,
newData: pslGraphicData.GatedRelateDevice newData: graphicData.DeviceCombinationtype
) { ) {
for (let i = 0; i < refDevicesList.length; i++) { for (let i = 0; i < refDevicesList.length; i++) {
if ( if (refDevicesList[i].code == editRow.code) {
refDevicesList[i].deviceType == editRow.deviceType &&
refDevicesList[i].code == editRow.code
) {
refDevicesList[i] = newData; refDevicesList[i] = newData;
break; break;
} }
@ -269,10 +262,7 @@ export function editGatedRelateDevice(
export function deleteGatedRelateDevice(row: RelateDevicelistItem) { export function deleteGatedRelateDevice(row: RelateDevicelistItem) {
for (let i = 0; i < refDevicesList.length; i++) { for (let i = 0; i < refDevicesList.length; i++) {
if ( if (refDevicesList[i].code == row.code) {
refDevicesList[i].deviceType == row.deviceType &&
refDevicesList[i].code == row.code
) {
refDevicesList.splice(i, 1); refDevicesList.splice(i, 1);
break; break;
} }

View File

@ -19,7 +19,7 @@ export namespace pslGraphicData {
pslButtons?: PslButton[]; pslButtons?: PslButton[];
pslKeys?: PslKey[]; pslKeys?: PslKey[];
pslTexts?: PslText[]; pslTexts?: PslText[];
gatedRelateDeviceList?: GatedRelateDevice[]; gatedRelateDeviceList?: dependency_1.graphicData.DeviceCombinationtype[];
}) { }) {
super(); super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6], this.#one_of_decls); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6], this.#one_of_decls);
@ -78,9 +78,9 @@ export namespace pslGraphicData {
pb_1.Message.setRepeatedWrapperField(this, 5, value); pb_1.Message.setRepeatedWrapperField(this, 5, value);
} }
get gatedRelateDeviceList() { get gatedRelateDeviceList() {
return pb_1.Message.getRepeatedWrapperField(this, GatedRelateDevice, 6) as GatedRelateDevice[]; return pb_1.Message.getRepeatedWrapperField(this, dependency_1.graphicData.DeviceCombinationtype, 6) as dependency_1.graphicData.DeviceCombinationtype[];
} }
set gatedRelateDeviceList(value: GatedRelateDevice[]) { set gatedRelateDeviceList(value: dependency_1.graphicData.DeviceCombinationtype[]) {
pb_1.Message.setRepeatedWrapperField(this, 6, value); pb_1.Message.setRepeatedWrapperField(this, 6, value);
} }
static fromObject(data: { static fromObject(data: {
@ -89,7 +89,7 @@ export namespace pslGraphicData {
pslButtons?: ReturnType<typeof PslButton.prototype.toObject>[]; pslButtons?: ReturnType<typeof PslButton.prototype.toObject>[];
pslKeys?: ReturnType<typeof PslKey.prototype.toObject>[]; pslKeys?: ReturnType<typeof PslKey.prototype.toObject>[];
pslTexts?: ReturnType<typeof PslText.prototype.toObject>[]; pslTexts?: ReturnType<typeof PslText.prototype.toObject>[];
gatedRelateDeviceList?: ReturnType<typeof GatedRelateDevice.prototype.toObject>[]; gatedRelateDeviceList?: ReturnType<typeof dependency_1.graphicData.DeviceCombinationtype.prototype.toObject>[];
}): PslGraphicStorage { }): PslGraphicStorage {
const message = new PslGraphicStorage({}); const message = new PslGraphicStorage({});
if (data.canvas != null) { if (data.canvas != null) {
@ -108,7 +108,7 @@ export namespace pslGraphicData {
message.pslTexts = data.pslTexts.map(item => PslText.fromObject(item)); message.pslTexts = data.pslTexts.map(item => PslText.fromObject(item));
} }
if (data.gatedRelateDeviceList != null) { if (data.gatedRelateDeviceList != null) {
message.gatedRelateDeviceList = data.gatedRelateDeviceList.map(item => GatedRelateDevice.fromObject(item)); message.gatedRelateDeviceList = data.gatedRelateDeviceList.map(item => dependency_1.graphicData.DeviceCombinationtype.fromObject(item));
} }
return message; return message;
} }
@ -119,7 +119,7 @@ export namespace pslGraphicData {
pslButtons?: ReturnType<typeof PslButton.prototype.toObject>[]; pslButtons?: ReturnType<typeof PslButton.prototype.toObject>[];
pslKeys?: ReturnType<typeof PslKey.prototype.toObject>[]; pslKeys?: ReturnType<typeof PslKey.prototype.toObject>[];
pslTexts?: ReturnType<typeof PslText.prototype.toObject>[]; pslTexts?: ReturnType<typeof PslText.prototype.toObject>[];
gatedRelateDeviceList?: ReturnType<typeof GatedRelateDevice.prototype.toObject>[]; gatedRelateDeviceList?: ReturnType<typeof dependency_1.graphicData.DeviceCombinationtype.prototype.toObject>[];
} = {}; } = {};
if (this.canvas != null) { if (this.canvas != null) {
data.canvas = this.canvas.toObject(); data.canvas = this.canvas.toObject();
@ -137,7 +137,7 @@ export namespace pslGraphicData {
data.pslTexts = this.pslTexts.map((item: PslText) => item.toObject()); data.pslTexts = this.pslTexts.map((item: PslText) => item.toObject());
} }
if (this.gatedRelateDeviceList != null) { if (this.gatedRelateDeviceList != null) {
data.gatedRelateDeviceList = this.gatedRelateDeviceList.map((item: GatedRelateDevice) => item.toObject()); data.gatedRelateDeviceList = this.gatedRelateDeviceList.map((item: dependency_1.graphicData.DeviceCombinationtype) => item.toObject());
} }
return data; return data;
} }
@ -156,7 +156,7 @@ export namespace pslGraphicData {
if (this.pslTexts.length) if (this.pslTexts.length)
writer.writeRepeatedMessage(5, this.pslTexts, (item: PslText) => item.serialize(writer)); writer.writeRepeatedMessage(5, this.pslTexts, (item: PslText) => item.serialize(writer));
if (this.gatedRelateDeviceList.length) if (this.gatedRelateDeviceList.length)
writer.writeRepeatedMessage(6, this.gatedRelateDeviceList, (item: GatedRelateDevice) => item.serialize(writer)); writer.writeRepeatedMessage(6, this.gatedRelateDeviceList, (item: dependency_1.graphicData.DeviceCombinationtype) => item.serialize(writer));
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -182,7 +182,7 @@ export namespace pslGraphicData {
reader.readMessage(message.pslTexts, () => pb_1.Message.addToRepeatedWrapperField(message, 5, PslText.deserialize(reader), PslText)); reader.readMessage(message.pslTexts, () => pb_1.Message.addToRepeatedWrapperField(message, 5, PslText.deserialize(reader), PslText));
break; break;
case 6: case 6:
reader.readMessage(message.gatedRelateDeviceList, () => pb_1.Message.addToRepeatedWrapperField(message, 6, GatedRelateDevice.deserialize(reader), GatedRelateDevice)); reader.readMessage(message.gatedRelateDeviceList, () => pb_1.Message.addToRepeatedWrapperField(message, 6, dependency_1.graphicData.DeviceCombinationtype.deserialize(reader), dependency_1.graphicData.DeviceCombinationtype));
break; break;
default: reader.skipField(); default: reader.skipField();
} }
@ -683,117 +683,4 @@ export namespace pslGraphicData {
return PslText.deserialize(bytes); return PslText.deserialize(bytes);
} }
} }
export class GatedRelateDevice extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
code?: string;
combinationtypes?: dependency_1.graphicData.DeviceCombinationtype[];
deviceType?: dependency_1.graphicData.RelatedRef.DeviceType;
}) {
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 ("code" in data && data.code != undefined) {
this.code = data.code;
}
if ("combinationtypes" in data && data.combinationtypes != undefined) {
this.combinationtypes = data.combinationtypes;
}
if ("deviceType" in data && data.deviceType != undefined) {
this.deviceType = data.deviceType;
}
}
}
get code() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set code(value: string) {
pb_1.Message.setField(this, 1, value);
}
get combinationtypes() {
return pb_1.Message.getRepeatedWrapperField(this, dependency_1.graphicData.DeviceCombinationtype, 2) as dependency_1.graphicData.DeviceCombinationtype[];
}
set combinationtypes(value: dependency_1.graphicData.DeviceCombinationtype[]) {
pb_1.Message.setRepeatedWrapperField(this, 2, value);
}
get deviceType() {
return pb_1.Message.getFieldWithDefault(this, 3, dependency_1.graphicData.RelatedRef.DeviceType.Section) as dependency_1.graphicData.RelatedRef.DeviceType;
}
set deviceType(value: dependency_1.graphicData.RelatedRef.DeviceType) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
code?: string;
combinationtypes?: ReturnType<typeof dependency_1.graphicData.DeviceCombinationtype.prototype.toObject>[];
deviceType?: dependency_1.graphicData.RelatedRef.DeviceType;
}): GatedRelateDevice {
const message = new GatedRelateDevice({});
if (data.code != null) {
message.code = data.code;
}
if (data.combinationtypes != null) {
message.combinationtypes = data.combinationtypes.map(item => dependency_1.graphicData.DeviceCombinationtype.fromObject(item));
}
if (data.deviceType != null) {
message.deviceType = data.deviceType;
}
return message;
}
toObject() {
const data: {
code?: string;
combinationtypes?: ReturnType<typeof dependency_1.graphicData.DeviceCombinationtype.prototype.toObject>[];
deviceType?: dependency_1.graphicData.RelatedRef.DeviceType;
} = {};
if (this.code != null) {
data.code = this.code;
}
if (this.combinationtypes != null) {
data.combinationtypes = this.combinationtypes.map((item: dependency_1.graphicData.DeviceCombinationtype) => item.toObject());
}
if (this.deviceType != null) {
data.deviceType = this.deviceType;
}
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.code.length)
writer.writeString(1, this.code);
if (this.combinationtypes.length)
writer.writeRepeatedMessage(2, this.combinationtypes, (item: dependency_1.graphicData.DeviceCombinationtype) => item.serialize(writer));
if (this.deviceType != dependency_1.graphicData.RelatedRef.DeviceType.Section)
writer.writeEnum(3, this.deviceType);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GatedRelateDevice {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GatedRelateDevice();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.code = reader.readString();
break;
case 2:
reader.readMessage(message.combinationtypes, () => pb_1.Message.addToRepeatedWrapperField(message, 2, dependency_1.graphicData.DeviceCombinationtype.deserialize(reader), dependency_1.graphicData.DeviceCombinationtype));
break;
case 3:
message.deviceType = reader.readEnum();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): GatedRelateDevice {
return GatedRelateDevice.deserialize(bytes);
}
}
} }