UNPKG

isoxml-angular

Version:

JavaScript library to parse and generate ISOXML (ISO11783-10) files

42 lines (41 loc) 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExtendedDeviceElement = void 0; const baseEntities_1 = require("../baseEntities"); const classRegistry_1 = require("../classRegistry"); class ExtendedDeviceElement extends baseEntities_1.DeviceElement { constructor(attributes, isoxmlManager) { super(attributes, isoxmlManager); this.tag = "DET" /* TAGS.DeviceElement */; } static fromXML(xml, isoxmlManager, internalId) { return baseEntities_1.DeviceElement.fromXML(xml, isoxmlManager, internalId, ExtendedDeviceElement); } getParentDevice() { return this.isoxmlManager.getEntitiesOfTag("DVC" /* TAGS.Device */).find(device => (device.attributes.DeviceElement || []).find(deviceElement => deviceElement === this)); } getValuePresentation(ddi) { const device = this.getParentDevice(); if (!device) { return null; } const processData = this.getDataProcess(ddi); const dvpObjectId = processData === null || processData === void 0 ? void 0 : processData.attributes.DeviceValuePresentationObjectId; if (!dvpObjectId) { return null; } return (device.attributes.DeviceValuePresentation || []) .find(dvp => dvp.attributes.DeviceValuePresentationObjectId === dvpObjectId); } getDataProcess(ddi) { const device = this.getParentDevice(); if (!device) { return null; } return (device.attributes.DeviceProcessData || []).find(dpd => dpd.attributes.DeviceProcessDataDDI === ddi && (this.attributes.DeviceObjectReference || []) .find(ref => ref.attributes.DeviceObjectId === dpd.attributes.DeviceProcessDataObjectId)); } } exports.ExtendedDeviceElement = ExtendedDeviceElement; (0, classRegistry_1.registerEntityClass)('main', "DET" /* TAGS.DeviceElement */, ExtendedDeviceElement);