UNPKG

isoxml

Version:

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

85 lines (84 loc) 2.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeviceElement = exports.DeviceElementDeviceElementTypeEnum = void 0; const constants_1 = require("./constants"); const classRegistry_1 = require("../classRegistry"); const utils_1 = require("../utils"); var DeviceElementDeviceElementTypeEnum; (function (DeviceElementDeviceElementTypeEnum) { DeviceElementDeviceElementTypeEnum["Device"] = "1"; DeviceElementDeviceElementTypeEnum["Function"] = "2"; DeviceElementDeviceElementTypeEnum["Bin"] = "3"; DeviceElementDeviceElementTypeEnum["Section"] = "4"; DeviceElementDeviceElementTypeEnum["Unit"] = "5"; DeviceElementDeviceElementTypeEnum["Connector"] = "6"; DeviceElementDeviceElementTypeEnum["Navigation"] = "7"; })(DeviceElementDeviceElementTypeEnum || (exports.DeviceElementDeviceElementTypeEnum = DeviceElementDeviceElementTypeEnum = {})); const ATTRIBUTES = { A: { name: 'DeviceElementId', type: 'xs:ID', isPrimaryId: true, isOptional: false, isOnlyV4: false, }, B: { name: 'DeviceElementObjectId', type: 'xs:unsignedShort', isPrimaryId: false, isOptional: false, isOnlyV4: false, minValue: 1, maxValue: 65534, }, C: { name: 'DeviceElementType', type: 'xs:NMTOKEN', isPrimaryId: false, isOptional: false, isOnlyV4: false, }, D: { name: 'DeviceElementDesignator', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, E: { name: 'DeviceElementNumber', type: 'xs:unsignedShort', isPrimaryId: false, isOptional: false, isOnlyV4: false, minValue: 0, maxValue: 4095, }, F: { name: 'ParentObjectId', type: 'xs:unsignedShort', isPrimaryId: false, isOptional: false, isOnlyV4: false, minValue: 0, maxValue: 65534, }, }; const CHILD_TAGS = { DOR: { name: 'DeviceObjectReference', isOnlyV4: false }, }; class DeviceElement { constructor(attributes, isoxmlManager) { this.attributes = attributes; this.isoxmlManager = isoxmlManager; this.tag = constants_1.TAGS.DeviceElement; } static fromXML(xml, isoxmlManager, internalId, targetClass = DeviceElement) { return (0, utils_1.fromXML)(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId); } toXML() { return (0, utils_1.toXML)(this, ATTRIBUTES, CHILD_TAGS); } } exports.DeviceElement = DeviceElement; (0, classRegistry_1.registerEntityClass)('main', constants_1.TAGS.DeviceElement, DeviceElement);