UNPKG

isoxml

Version:

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

79 lines (78 loc) 2.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Device = void 0; const constants_1 = require("./constants"); const classRegistry_1 = require("../classRegistry"); const utils_1 = require("../utils"); const ATTRIBUTES = { A: { name: 'DeviceId', type: 'xs:ID', isPrimaryId: true, isOptional: false, isOnlyV4: false, }, B: { name: 'DeviceDesignator', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, C: { name: 'DeviceSoftwareVersion', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, D: { name: 'ClientNAME', type: 'xs:hexBinary', isPrimaryId: false, isOptional: false, isOnlyV4: false, }, E: { name: 'DeviceSerialNumber', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, F: { name: 'DeviceStructureLabel', type: 'xs:hexBinary', isPrimaryId: false, isOptional: false, isOnlyV4: false, }, G: { name: 'DeviceLocalizationLabel', type: 'xs:hexBinary', isPrimaryId: false, isOptional: false, isOnlyV4: false, }, }; const CHILD_TAGS = { DET: { name: 'DeviceElement', isOnlyV4: false }, DPT: { name: 'DeviceProperty', isOnlyV4: false }, DPD: { name: 'DeviceProcessData', isOnlyV4: false }, DVP: { name: 'DeviceValuePresentation', isOnlyV4: false }, }; class Device { constructor(attributes, isoxmlManager) { this.attributes = attributes; this.isoxmlManager = isoxmlManager; this.tag = constants_1.TAGS.Device; } static fromXML(xml, isoxmlManager, internalId, targetClass = Device) { return (0, utils_1.fromXML)(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId); } toXML() { return (0, utils_1.toXML)(this, ATTRIBUTES, CHILD_TAGS); } } exports.Device = Device; (0, classRegistry_1.registerEntityClass)('main', constants_1.TAGS.Device, Device);