UNPKG

isoxml

Version:

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

64 lines (63 loc) 1.74 kB
import { TAGS } from './constants'; import { registerEntityClass } from '../classRegistry'; import { fromXML, toXML } from '../utils'; const ATTRIBUTES = { A: { name: 'DeviceValuePresentationObjectId', type: 'xs:unsignedShort', isPrimaryId: false, isOptional: false, isOnlyV4: false, minValue: 1, maxValue: 65534, }, B: { name: 'Offset', type: 'xs:long', isPrimaryId: false, isOptional: false, isOnlyV4: false, minValue: -2147483648, maxValue: 2147483647, }, C: { name: 'Scale', type: 'xs:decimal', isPrimaryId: false, isOptional: false, isOnlyV4: false, minValue: 1e-9, maxValue: 100000000, }, D: { name: 'NumberOfDecimals', type: 'xs:unsignedByte', isPrimaryId: false, isOptional: false, isOnlyV4: false, minValue: 0, maxValue: 7, }, E: { name: 'UnitDesignator', type: 'xs:string', isPrimaryId: false, isOptional: true, isOnlyV4: false, }, }; const CHILD_TAGS = {}; export class DeviceValuePresentation { constructor(attributes, isoxmlManager) { this.attributes = attributes; this.isoxmlManager = isoxmlManager; this.tag = TAGS.DeviceValuePresentation; } static fromXML(xml, isoxmlManager, internalId, targetClass = DeviceValuePresentation) { return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId); } toXML() { return toXML(this, ATTRIBUTES, CHILD_TAGS); } } registerEntityClass('main', TAGS.DeviceValuePresentation, DeviceValuePresentation);