场景添加继电器关联设备显示

This commit is contained in:
joylink_zhaoerwei 2023-10-07 09:32:33 +08:00
parent fd68a78bf6
commit 971929e867

View File

@ -12,7 +12,7 @@ import { toUint8Array } from 'js-base64';
import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics';
import { RelayCabinetTemplate } from 'src/graphics/relayCabinet/RelayCabinet';
import { RelayCabinetData } from './relayCabinetGraphics/RelayCabinetInteraction';
import { RelayTemplate } from 'src/graphics/relay/Relay';
import { Relay, RelayTemplate } from 'src/graphics/relay/Relay';
import { RelayData, RelayState } from './relayCabinetGraphics/RelayInteraction';
import { PhaseFailureProtectorTemplate } from 'src/graphics/phaseFailureProtector/PhaseFailureProtector';
import { PhaseFailureProtectorData } from './relayCabinetGraphics/PhaseFailureProtectorInteraction';
@ -37,6 +37,21 @@ export function initRelayScene(lineApp: IGraphicApp, sceneName: string) {
relayScene.registerGraphicTemplates(...relayGraphicTemplate);
relayScene.on('postdataloaded', () => {
handleSubscribe(relayScene);
const map = new Map<string, string>();
refRelaysList.forEach((device) => {
device.combinationtypes.forEach((combinationtype) => {
combinationtype.refRelays.forEach((relayId) => {
map.set(relayId, device.code);
});
});
});
const relays = relayScene.queryStore.queryByType<Relay>(Relay.Type);
relays.forEach((relay) => {
relay.refDevice.text = map.get(relay.id) as string;
});
});
relayScene.on('destroy', async () => {
refRelaysList = [];
});
}
@ -91,6 +106,7 @@ function handleSubscribe(relayScene: IGraphicScene) {
});
}
let refRelaysList: relayCabinetGraphicData.DeviceRelateRelay[] = [];
async function loadRelayDatas(): Promise<IGraphicStorage> {
const lineStore = useLineStore();
const mapId = lineStore.mapId;
@ -114,6 +130,7 @@ async function loadRelayDatas(): Promise<IGraphicStorage> {
storage.phaseFailureProtectors.forEach((phaseFailureProtector) => {
datas.push(new PhaseFailureProtectorData(phaseFailureProtector));
});
refRelaysList = storage.deviceRelateRelayList;
return Promise.resolve({
canvasProperty: storage.canvas,
datas: datas,