新的ISCS数据结构实现加载赞提

This commit is contained in:
joylink_zhaoerwei 2024-09-25 14:54:46 +08:00
parent dede7f400f
commit 320c1e92cc
5 changed files with 533 additions and 130 deletions

View File

@ -57,26 +57,68 @@ export function initIscsDrawApp(): IDrawApp {
},
})
);
app.on('destroy', async () => {
resetData();
});
return drawApp;
}
let hasLoadData = false;
let base64 = '';
export async function loadDrawDatas(): Promise<IGraphicStorage> {
const drawStore = useDrawStore();
const id = drawStore.draftId;
if (!id) {
throw new Error('获取数据异常为获取到草稿地图ID');
}
const { data: base64 } = await getDraft(id);
if (!hasLoadData) {
base64 = (await getDraft(id)).data;
hasLoadData = true;
}
if (base64) {
const storage = iscsGraphicData.IscsGraphicStorage.deserialize(
storage = iscsGraphicData.IscsGraphicStorage.deserialize(
toUint8Array(base64)
);
const datas = loadCommonDrawDatas(storage);
storage.cctvButtons.forEach((cctvButton) => {
datas.push(new CCTVButtonData(cctvButton));
});
let datas = [];
let canvasProperty;
switch (drawStore.selectSubmenuAndStation.submenu) {
case '站台报警':
for (let i = 0; i < storage.fasPlatformAlarmStorages.length; i++) {
const fasPlatformAlarm = storage.fasPlatformAlarmStorages[i];
if (
fasPlatformAlarm.stationName ==
drawStore.selectSubmenuAndStation.station
) {
canvasProperty = fasPlatformAlarm.canvas;
datas = loadCommonDrawDatas(fasPlatformAlarm);
break;
}
}
break;
case '车站控制':
for (let i = 0; i < storage.cctvOfStationControlStorages.length; i++) {
const ctvOfStationControl = storage.cctvOfStationControlStorages[i];
if (
ctvOfStationControl.stationName ==
drawStore.selectSubmenuAndStation.station
) {
canvasProperty = ctvOfStationControl.canvas;
datas = loadCommonDrawDatas(ctvOfStationControl);
ctvOfStationControl.cctvButtons.forEach((cctvButton) => {
datas.push(new CCTVButtonData(cctvButton));
});
break;
}
}
default:
break;
}
return {
canvasProperty: storage.canvas,
canvasProperty,
datas: datas,
};
} else {
@ -86,12 +128,69 @@ export async function loadDrawDatas(): Promise<IGraphicStorage> {
}
}
const stationOption = ['会展中心', '火车站', '丈八一路'];
let storage: iscsGraphicData.IscsGraphicStorage;
export function saveDrawDatas(app: IDrawApp) {
let storage = new iscsGraphicData.IscsGraphicStorage();
storage = saveCommonDrawDatas(
app,
storage
) as iscsGraphicData.IscsGraphicStorage;
const drawStore = useDrawStore();
if (!storage) {
storage = new iscsGraphicData.IscsGraphicStorage();
}
if (!storage?.fasPlatformAlarmStorages.length) {
stationOption.forEach((station) =>
storage?.fasPlatformAlarmStorages.push(
new iscsGraphicData.FASPlatformAlarmStorage({
stationName: station,
})
)
);
}
if (!storage?.cctvOfStationControlStorages.length) {
stationOption.forEach((station) =>
storage?.cctvOfStationControlStorages.push(
new iscsGraphicData.CCTVOfStationControlStorage({
stationName: station,
})
)
);
}
switch (drawStore.selectSubmenuAndStation.submenu) {
case '站台报警':
for (let i = 0; i < storage.fasPlatformAlarmStorages.length; i++) {
const asPlatformAlarm = storage.fasPlatformAlarmStorages[i];
if (
asPlatformAlarm.stationName ==
drawStore.selectSubmenuAndStation.station
) {
const fasStorage = saveCommonDrawDatas(
app,
asPlatformAlarm
) as iscsGraphicData.FASPlatformAlarmStorage;
storage.fasPlatformAlarmStorages[i] = fasStorage;
break;
}
}
break;
case '车站控制':
for (let i = 0; i < storage.cctvOfStationControlStorages.length; i++) {
const cctvOfStationControl = storage.cctvOfStationControlStorages[i];
if (
cctvOfStationControl.stationName ==
drawStore.selectSubmenuAndStation.station
) {
const cctvStorage = saveCommonDrawDatas(
app,
cctvOfStationControl
) as iscsGraphicData.CCTVOfStationControlStorage;
storage.cctvOfStationControlStorages[i] = cctvStorage;
break;
}
}
break;
default:
break;
}
const graphics = app.queryStore.getAllGraphics();
/* graphics.forEach((g) => {
if (TrackSection.Type === g.type) {
@ -102,3 +201,9 @@ export function saveDrawDatas(app: IDrawApp) {
const base64 = fromUint8Array(storage.serialize());
return base64;
}
function resetData() {
storage = new iscsGraphicData.IscsGraphicStorage();
hasLoadData = false;
base64 = '';
}

View File

@ -35,6 +35,12 @@
</q-list>
</q-btn-dropdown>
</template>
<q-btn-toggle
v-model="selectStationName"
toggle-color="orange"
:options="stationOption"
@update:model-value="selectedStation"
/>
</q-toolbar-title>
<q-btn square color="purple" style="margin-right: 10px" icon="search">
<q-popup-edit
@ -139,7 +145,7 @@
<script setup lang="ts">
import DrawProperties from 'src/components/draw-app/IscsDrawProperties.vue';
import { onMounted, reactive, ref, watch } from 'vue';
import { onMounted, onUnmounted, reactive, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import { useDrawStore } from 'src/stores/draw-store';
@ -319,11 +325,31 @@ async function saveAs(name: string) {
}
function onTopMenuClick(name: string) {
console.log(name);
drawStore.clickSubmenuName = name;
drawStore.selectSubmenuAndStation.submenu = name;
forceReloadDate();
}
function forceReloadDate() {
const drawApp = drawStore.getDrawApp();
const graphics = drawApp.queryStore.getAllGraphics();
graphics.forEach((graphic) => (graphic.visible = false));
drawApp.updateSelected();
drawApp.forceReload();
}
//
const selectStationName = ref('会展中心');
const stationOption = [
{ label: '会展中心', value: '会展中心' },
{ label: '火车站', value: '火车站' },
{ label: '丈八一路', value: '丈八一路' },
];
function selectedStation(name: string) {
drawStore.selectSubmenuAndStation.station = name;
forceReloadDate();
}
onUnmounted(() => {
drawStore.destroy();
});
</script>

View File

@ -278,7 +278,6 @@ import {
} from 'src/api/PublishApi';
import { useAuthStore } from 'src/stores/auth-store';
import { PageDto } from 'src/api/ApiCommon';
import { useDrawStore } from 'src/stores/draw-store';
const $q = useQuasar();
const router = useRouter();
@ -289,7 +288,6 @@ const props = withDefaults(
{ sizeHeight: 500 }
);
const authStore = useAuthStore();
const drawStore = useDrawStore();
const route = useRoute();
const tableHeight = computed(() => {
@ -469,7 +467,6 @@ function onCreate() {
//
function goToPath(row: DraftItem) {
drawStore.clickSubmenuName = '车站控制';
let path = `/iscsPainting/${row.id}`;
const iscsStyle = allRequestData.find((item) => item.draftData.id == row.id)
.options.style;

View File

@ -9,112 +9,55 @@ export namespace iscsGraphicData {
export class IscsGraphicStorage extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
canvas?: dependency_1.common.Canvas;
arrows?: Arrow[];
iscsTexts?: IscsText[];
rects?: Rect[];
cctvButtons?: CCTVButton[];
cctvOfStationControlStorages?: CCTVOfStationControlStorage[];
fasPlatformAlarmStorages?: FASPlatformAlarmStorage[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5], 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 ("canvas" in data && data.canvas != undefined) {
this.canvas = data.canvas;
if ("cctvOfStationControlStorages" in data && data.cctvOfStationControlStorages != undefined) {
this.cctvOfStationControlStorages = data.cctvOfStationControlStorages;
}
if ("arrows" in data && data.arrows != undefined) {
this.arrows = data.arrows;
}
if ("iscsTexts" in data && data.iscsTexts != undefined) {
this.iscsTexts = data.iscsTexts;
}
if ("rects" in data && data.rects != undefined) {
this.rects = data.rects;
}
if ("cctvButtons" in data && data.cctvButtons != undefined) {
this.cctvButtons = data.cctvButtons;
if ("fasPlatformAlarmStorages" in data && data.fasPlatformAlarmStorages != undefined) {
this.fasPlatformAlarmStorages = data.fasPlatformAlarmStorages;
}
}
}
get canvas() {
return pb_1.Message.getWrapperField(this, dependency_1.common.Canvas, 1) as dependency_1.common.Canvas;
get cctvOfStationControlStorages() {
return pb_1.Message.getRepeatedWrapperField(this, CCTVOfStationControlStorage, 1) as CCTVOfStationControlStorage[];
}
set canvas(value: dependency_1.common.Canvas) {
pb_1.Message.setWrapperField(this, 1, value);
set cctvOfStationControlStorages(value: CCTVOfStationControlStorage[]) {
pb_1.Message.setRepeatedWrapperField(this, 1, value);
}
get has_canvas() {
return pb_1.Message.getField(this, 1) != null;
get fasPlatformAlarmStorages() {
return pb_1.Message.getRepeatedWrapperField(this, FASPlatformAlarmStorage, 2) as FASPlatformAlarmStorage[];
}
get arrows() {
return pb_1.Message.getRepeatedWrapperField(this, Arrow, 2) as Arrow[];
}
set arrows(value: Arrow[]) {
set fasPlatformAlarmStorages(value: FASPlatformAlarmStorage[]) {
pb_1.Message.setRepeatedWrapperField(this, 2, value);
}
get iscsTexts() {
return pb_1.Message.getRepeatedWrapperField(this, IscsText, 3) as IscsText[];
}
set iscsTexts(value: IscsText[]) {
pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
get rects() {
return pb_1.Message.getRepeatedWrapperField(this, Rect, 4) as Rect[];
}
set rects(value: Rect[]) {
pb_1.Message.setRepeatedWrapperField(this, 4, value);
}
get cctvButtons() {
return pb_1.Message.getRepeatedWrapperField(this, CCTVButton, 5) as CCTVButton[];
}
set cctvButtons(value: CCTVButton[]) {
pb_1.Message.setRepeatedWrapperField(this, 5, value);
}
static fromObject(data: {
canvas?: ReturnType<typeof dependency_1.common.Canvas.prototype.toObject>;
arrows?: ReturnType<typeof Arrow.prototype.toObject>[];
iscsTexts?: ReturnType<typeof IscsText.prototype.toObject>[];
rects?: ReturnType<typeof Rect.prototype.toObject>[];
cctvButtons?: ReturnType<typeof CCTVButton.prototype.toObject>[];
cctvOfStationControlStorages?: ReturnType<typeof CCTVOfStationControlStorage.prototype.toObject>[];
fasPlatformAlarmStorages?: ReturnType<typeof FASPlatformAlarmStorage.prototype.toObject>[];
}): IscsGraphicStorage {
const message = new IscsGraphicStorage({});
if (data.canvas != null) {
message.canvas = dependency_1.common.Canvas.fromObject(data.canvas);
if (data.cctvOfStationControlStorages != null) {
message.cctvOfStationControlStorages = data.cctvOfStationControlStorages.map(item => CCTVOfStationControlStorage.fromObject(item));
}
if (data.arrows != null) {
message.arrows = data.arrows.map(item => Arrow.fromObject(item));
}
if (data.iscsTexts != null) {
message.iscsTexts = data.iscsTexts.map(item => IscsText.fromObject(item));
}
if (data.rects != null) {
message.rects = data.rects.map(item => Rect.fromObject(item));
}
if (data.cctvButtons != null) {
message.cctvButtons = data.cctvButtons.map(item => CCTVButton.fromObject(item));
if (data.fasPlatformAlarmStorages != null) {
message.fasPlatformAlarmStorages = data.fasPlatformAlarmStorages.map(item => FASPlatformAlarmStorage.fromObject(item));
}
return message;
}
toObject() {
const data: {
canvas?: ReturnType<typeof dependency_1.common.Canvas.prototype.toObject>;
arrows?: ReturnType<typeof Arrow.prototype.toObject>[];
iscsTexts?: ReturnType<typeof IscsText.prototype.toObject>[];
rects?: ReturnType<typeof Rect.prototype.toObject>[];
cctvButtons?: ReturnType<typeof CCTVButton.prototype.toObject>[];
cctvOfStationControlStorages?: ReturnType<typeof CCTVOfStationControlStorage.prototype.toObject>[];
fasPlatformAlarmStorages?: ReturnType<typeof FASPlatformAlarmStorage.prototype.toObject>[];
} = {};
if (this.canvas != null) {
data.canvas = this.canvas.toObject();
if (this.cctvOfStationControlStorages != null) {
data.cctvOfStationControlStorages = this.cctvOfStationControlStorages.map((item: CCTVOfStationControlStorage) => item.toObject());
}
if (this.arrows != null) {
data.arrows = this.arrows.map((item: Arrow) => item.toObject());
}
if (this.iscsTexts != null) {
data.iscsTexts = this.iscsTexts.map((item: IscsText) => item.toObject());
}
if (this.rects != null) {
data.rects = this.rects.map((item: Rect) => item.toObject());
}
if (this.cctvButtons != null) {
data.cctvButtons = this.cctvButtons.map((item: CCTVButton) => item.toObject());
if (this.fasPlatformAlarmStorages != null) {
data.fasPlatformAlarmStorages = this.fasPlatformAlarmStorages.map((item: FASPlatformAlarmStorage) => item.toObject());
}
return data;
}
@ -122,16 +65,10 @@ export namespace iscsGraphicData {
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.has_canvas)
writer.writeMessage(1, this.canvas, () => this.canvas.serialize(writer));
if (this.arrows.length)
writer.writeRepeatedMessage(2, this.arrows, (item: Arrow) => item.serialize(writer));
if (this.iscsTexts.length)
writer.writeRepeatedMessage(3, this.iscsTexts, (item: IscsText) => item.serialize(writer));
if (this.rects.length)
writer.writeRepeatedMessage(4, this.rects, (item: Rect) => item.serialize(writer));
if (this.cctvButtons.length)
writer.writeRepeatedMessage(5, this.cctvButtons, (item: CCTVButton) => item.serialize(writer));
if (this.cctvOfStationControlStorages.length)
writer.writeRepeatedMessage(1, this.cctvOfStationControlStorages, (item: CCTVOfStationControlStorage) => item.serialize(writer));
if (this.fasPlatformAlarmStorages.length)
writer.writeRepeatedMessage(2, this.fasPlatformAlarmStorages, (item: FASPlatformAlarmStorage) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
@ -142,19 +79,10 @@ export namespace iscsGraphicData {
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.canvas, () => message.canvas = dependency_1.common.Canvas.deserialize(reader));
reader.readMessage(message.cctvOfStationControlStorages, () => pb_1.Message.addToRepeatedWrapperField(message, 1, CCTVOfStationControlStorage.deserialize(reader), CCTVOfStationControlStorage));
break;
case 2:
reader.readMessage(message.arrows, () => pb_1.Message.addToRepeatedWrapperField(message, 2, Arrow.deserialize(reader), Arrow));
break;
case 3:
reader.readMessage(message.iscsTexts, () => pb_1.Message.addToRepeatedWrapperField(message, 3, IscsText.deserialize(reader), IscsText));
break;
case 4:
reader.readMessage(message.rects, () => pb_1.Message.addToRepeatedWrapperField(message, 4, Rect.deserialize(reader), Rect));
break;
case 5:
reader.readMessage(message.cctvButtons, () => pb_1.Message.addToRepeatedWrapperField(message, 5, CCTVButton.deserialize(reader), CCTVButton));
reader.readMessage(message.fasPlatformAlarmStorages, () => pb_1.Message.addToRepeatedWrapperField(message, 2, FASPlatformAlarmStorage.deserialize(reader), FASPlatformAlarmStorage));
break;
default: reader.skipField();
}
@ -1381,4 +1309,351 @@ export namespace iscsGraphicData {
return TemperatureDetector.deserialize(bytes);
}
}
export class CCTVOfStationControlStorage extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
stationName?: string;
canvas?: dependency_1.common.Canvas;
arrows?: Arrow[];
iscsTexts?: IscsText[];
rects?: Rect[];
cctvButtons?: CCTVButton[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 4, 5, 6], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("stationName" in data && data.stationName != undefined) {
this.stationName = data.stationName;
}
if ("canvas" in data && data.canvas != undefined) {
this.canvas = data.canvas;
}
if ("arrows" in data && data.arrows != undefined) {
this.arrows = data.arrows;
}
if ("iscsTexts" in data && data.iscsTexts != undefined) {
this.iscsTexts = data.iscsTexts;
}
if ("rects" in data && data.rects != undefined) {
this.rects = data.rects;
}
if ("cctvButtons" in data && data.cctvButtons != undefined) {
this.cctvButtons = data.cctvButtons;
}
}
}
get stationName() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set stationName(value: string) {
pb_1.Message.setField(this, 1, value);
}
get canvas() {
return pb_1.Message.getWrapperField(this, dependency_1.common.Canvas, 2) as dependency_1.common.Canvas;
}
set canvas(value: dependency_1.common.Canvas) {
pb_1.Message.setWrapperField(this, 2, value);
}
get has_canvas() {
return pb_1.Message.getField(this, 2) != null;
}
get arrows() {
return pb_1.Message.getRepeatedWrapperField(this, Arrow, 3) as Arrow[];
}
set arrows(value: Arrow[]) {
pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
get iscsTexts() {
return pb_1.Message.getRepeatedWrapperField(this, IscsText, 4) as IscsText[];
}
set iscsTexts(value: IscsText[]) {
pb_1.Message.setRepeatedWrapperField(this, 4, value);
}
get rects() {
return pb_1.Message.getRepeatedWrapperField(this, Rect, 5) as Rect[];
}
set rects(value: Rect[]) {
pb_1.Message.setRepeatedWrapperField(this, 5, value);
}
get cctvButtons() {
return pb_1.Message.getRepeatedWrapperField(this, CCTVButton, 6) as CCTVButton[];
}
set cctvButtons(value: CCTVButton[]) {
pb_1.Message.setRepeatedWrapperField(this, 6, value);
}
static fromObject(data: {
stationName?: string;
canvas?: ReturnType<typeof dependency_1.common.Canvas.prototype.toObject>;
arrows?: ReturnType<typeof Arrow.prototype.toObject>[];
iscsTexts?: ReturnType<typeof IscsText.prototype.toObject>[];
rects?: ReturnType<typeof Rect.prototype.toObject>[];
cctvButtons?: ReturnType<typeof CCTVButton.prototype.toObject>[];
}): CCTVOfStationControlStorage {
const message = new CCTVOfStationControlStorage({});
if (data.stationName != null) {
message.stationName = data.stationName;
}
if (data.canvas != null) {
message.canvas = dependency_1.common.Canvas.fromObject(data.canvas);
}
if (data.arrows != null) {
message.arrows = data.arrows.map(item => Arrow.fromObject(item));
}
if (data.iscsTexts != null) {
message.iscsTexts = data.iscsTexts.map(item => IscsText.fromObject(item));
}
if (data.rects != null) {
message.rects = data.rects.map(item => Rect.fromObject(item));
}
if (data.cctvButtons != null) {
message.cctvButtons = data.cctvButtons.map(item => CCTVButton.fromObject(item));
}
return message;
}
toObject() {
const data: {
stationName?: string;
canvas?: ReturnType<typeof dependency_1.common.Canvas.prototype.toObject>;
arrows?: ReturnType<typeof Arrow.prototype.toObject>[];
iscsTexts?: ReturnType<typeof IscsText.prototype.toObject>[];
rects?: ReturnType<typeof Rect.prototype.toObject>[];
cctvButtons?: ReturnType<typeof CCTVButton.prototype.toObject>[];
} = {};
if (this.stationName != null) {
data.stationName = this.stationName;
}
if (this.canvas != null) {
data.canvas = this.canvas.toObject();
}
if (this.arrows != null) {
data.arrows = this.arrows.map((item: Arrow) => item.toObject());
}
if (this.iscsTexts != null) {
data.iscsTexts = this.iscsTexts.map((item: IscsText) => item.toObject());
}
if (this.rects != null) {
data.rects = this.rects.map((item: Rect) => item.toObject());
}
if (this.cctvButtons != null) {
data.cctvButtons = this.cctvButtons.map((item: CCTVButton) => 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.stationName.length)
writer.writeString(1, this.stationName);
if (this.has_canvas)
writer.writeMessage(2, this.canvas, () => this.canvas.serialize(writer));
if (this.arrows.length)
writer.writeRepeatedMessage(3, this.arrows, (item: Arrow) => item.serialize(writer));
if (this.iscsTexts.length)
writer.writeRepeatedMessage(4, this.iscsTexts, (item: IscsText) => item.serialize(writer));
if (this.rects.length)
writer.writeRepeatedMessage(5, this.rects, (item: Rect) => item.serialize(writer));
if (this.cctvButtons.length)
writer.writeRepeatedMessage(6, this.cctvButtons, (item: CCTVButton) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CCTVOfStationControlStorage {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CCTVOfStationControlStorage();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.stationName = reader.readString();
break;
case 2:
reader.readMessage(message.canvas, () => message.canvas = dependency_1.common.Canvas.deserialize(reader));
break;
case 3:
reader.readMessage(message.arrows, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Arrow.deserialize(reader), Arrow));
break;
case 4:
reader.readMessage(message.iscsTexts, () => pb_1.Message.addToRepeatedWrapperField(message, 4, IscsText.deserialize(reader), IscsText));
break;
case 5:
reader.readMessage(message.rects, () => pb_1.Message.addToRepeatedWrapperField(message, 5, Rect.deserialize(reader), Rect));
break;
case 6:
reader.readMessage(message.cctvButtons, () => pb_1.Message.addToRepeatedWrapperField(message, 6, CCTVButton.deserialize(reader), CCTVButton));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): CCTVOfStationControlStorage {
return CCTVOfStationControlStorage.deserialize(bytes);
}
}
export class FASPlatformAlarmStorage extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
stationName?: string;
canvas?: dependency_1.common.Canvas;
arrows?: Arrow[];
iscsTexts?: IscsText[];
rects?: Rect[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 4, 5], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("stationName" in data && data.stationName != undefined) {
this.stationName = data.stationName;
}
if ("canvas" in data && data.canvas != undefined) {
this.canvas = data.canvas;
}
if ("arrows" in data && data.arrows != undefined) {
this.arrows = data.arrows;
}
if ("iscsTexts" in data && data.iscsTexts != undefined) {
this.iscsTexts = data.iscsTexts;
}
if ("rects" in data && data.rects != undefined) {
this.rects = data.rects;
}
}
}
get stationName() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set stationName(value: string) {
pb_1.Message.setField(this, 1, value);
}
get canvas() {
return pb_1.Message.getWrapperField(this, dependency_1.common.Canvas, 2) as dependency_1.common.Canvas;
}
set canvas(value: dependency_1.common.Canvas) {
pb_1.Message.setWrapperField(this, 2, value);
}
get has_canvas() {
return pb_1.Message.getField(this, 2) != null;
}
get arrows() {
return pb_1.Message.getRepeatedWrapperField(this, Arrow, 3) as Arrow[];
}
set arrows(value: Arrow[]) {
pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
get iscsTexts() {
return pb_1.Message.getRepeatedWrapperField(this, IscsText, 4) as IscsText[];
}
set iscsTexts(value: IscsText[]) {
pb_1.Message.setRepeatedWrapperField(this, 4, value);
}
get rects() {
return pb_1.Message.getRepeatedWrapperField(this, Rect, 5) as Rect[];
}
set rects(value: Rect[]) {
pb_1.Message.setRepeatedWrapperField(this, 5, value);
}
static fromObject(data: {
stationName?: string;
canvas?: ReturnType<typeof dependency_1.common.Canvas.prototype.toObject>;
arrows?: ReturnType<typeof Arrow.prototype.toObject>[];
iscsTexts?: ReturnType<typeof IscsText.prototype.toObject>[];
rects?: ReturnType<typeof Rect.prototype.toObject>[];
}): FASPlatformAlarmStorage {
const message = new FASPlatformAlarmStorage({});
if (data.stationName != null) {
message.stationName = data.stationName;
}
if (data.canvas != null) {
message.canvas = dependency_1.common.Canvas.fromObject(data.canvas);
}
if (data.arrows != null) {
message.arrows = data.arrows.map(item => Arrow.fromObject(item));
}
if (data.iscsTexts != null) {
message.iscsTexts = data.iscsTexts.map(item => IscsText.fromObject(item));
}
if (data.rects != null) {
message.rects = data.rects.map(item => Rect.fromObject(item));
}
return message;
}
toObject() {
const data: {
stationName?: string;
canvas?: ReturnType<typeof dependency_1.common.Canvas.prototype.toObject>;
arrows?: ReturnType<typeof Arrow.prototype.toObject>[];
iscsTexts?: ReturnType<typeof IscsText.prototype.toObject>[];
rects?: ReturnType<typeof Rect.prototype.toObject>[];
} = {};
if (this.stationName != null) {
data.stationName = this.stationName;
}
if (this.canvas != null) {
data.canvas = this.canvas.toObject();
}
if (this.arrows != null) {
data.arrows = this.arrows.map((item: Arrow) => item.toObject());
}
if (this.iscsTexts != null) {
data.iscsTexts = this.iscsTexts.map((item: IscsText) => item.toObject());
}
if (this.rects != null) {
data.rects = this.rects.map((item: Rect) => 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.stationName.length)
writer.writeString(1, this.stationName);
if (this.has_canvas)
writer.writeMessage(2, this.canvas, () => this.canvas.serialize(writer));
if (this.arrows.length)
writer.writeRepeatedMessage(3, this.arrows, (item: Arrow) => item.serialize(writer));
if (this.iscsTexts.length)
writer.writeRepeatedMessage(4, this.iscsTexts, (item: IscsText) => item.serialize(writer));
if (this.rects.length)
writer.writeRepeatedMessage(5, this.rects, (item: Rect) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): FASPlatformAlarmStorage {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new FASPlatformAlarmStorage();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.stationName = reader.readString();
break;
case 2:
reader.readMessage(message.canvas, () => message.canvas = dependency_1.common.Canvas.deserialize(reader));
break;
case 3:
reader.readMessage(message.arrows, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Arrow.deserialize(reader), Arrow));
break;
case 4:
reader.readMessage(message.iscsTexts, () => pb_1.Message.addToRepeatedWrapperField(message, 4, IscsText.deserialize(reader), IscsText));
break;
case 5:
reader.readMessage(message.rects, () => pb_1.Message.addToRepeatedWrapperField(message, 5, Rect.deserialize(reader), Rect));
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): FASPlatformAlarmStorage {
return FASPlatformAlarmStorage.deserialize(bytes);
}
}
}

View File

@ -20,17 +20,13 @@ export const useDrawStore = defineStore('draw', {
selectedGraphics: null as JlGraphic[] | null,
draftId: null as number | null,
drawPictureType: null as PictureType | null,
clickSubmenuName: '车站控制',
selectSubmenuAndStation: { submenu: '站台报警', station: '会展中心' },
}),
getters: {
drawMode: (state) => state.drawAssistant != null,
drawGraphicType: (state) => state.drawAssistant?.type,
drawGraphicName: (state) => state.drawAssistant?.description,
drawGraphicTemplate: (state) => state.drawAssistant?.graphicTemplate,
getApp: () => {
const app = getIscsDrawApp();
return app;
},
selectedGraphicType: (state) => {
if (state.selectedGraphics) {
if (state.selectedGraphics.length === 1) {
@ -43,7 +39,7 @@ export const useDrawStore = defineStore('draw', {
if (state.selectedGraphics.length == 0) {
return '画布';
} else if (state.selectedGraphics.length == 1) {
const name = this.getApp?.getDrawAssistant(
const name = getIscsDrawApp()?.getDrawAssistant(
state.selectedGraphics[0].type
).description;
return name || '';
@ -63,7 +59,7 @@ export const useDrawStore = defineStore('draw', {
},
actions: {
getDrawApp(): IDrawApp {
const app = this.getApp;
const app = getIscsDrawApp();
if (app == null) {
throw new Error('未初始化app');
}
@ -104,7 +100,11 @@ export const useDrawStore = defineStore('draw', {
// console.log('绘制状态清空,绘制应用销毁');
this.drawAssistant = null;
this.selectedGraphics = null;
destroyIscsDrawApp();
(this.selectSubmenuAndStation = {
submenu: '站台报警',
station: '会展中心',
}),
destroyIscsDrawApp();
},
setDraftId(id: number | null) {
this.draftId = id;