UNPKG

isoxml

Version:

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

81 lines (80 loc) 2.45 kB
import { TAGS } from './constants'; import { registerEntityClass } from '../classRegistry'; import { fromXML, toXML } from '../utils'; export 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 || (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 }, }; export class DeviceElement { constructor(attributes, isoxmlManager) { this.attributes = attributes; this.isoxmlManager = isoxmlManager; this.tag = TAGS.DeviceElement; } static fromXML(xml, isoxmlManager, internalId, targetClass = DeviceElement) { return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId); } toXML() { return toXML(this, ATTRIBUTES, CHILD_TAGS); } } registerEntityClass('main', TAGS.DeviceElement, DeviceElement);