How to use the node-opcua-factory.findBuiltInType function in node-opcua-factory

To help you get started, we’ve selected a few node-opcua-factory examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-address-space-for-conformance-testing / src / address_space_for_conformance_testing.js View on Github external
function _findDataType(dataTypeName) {
    const builtInDataTypeName = findBuiltInType(dataTypeName);
    const dataType = DataType[builtInDataTypeName.name];
    // istanbul ignore next
    if (!dataType) {
        throw new Error(" dataType " + dataTypeName + " must exists");
    }
    return dataType;
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / extension_object_array_node.js View on Github external
field.$$isEnum$$ = false;
        field.$$isStructure$$ = false;
        if (fieldDataType.isSupertypeOf(enumeration)) {
            field.$$isEnum$$ = true;
            makeEnumeration(fieldDataType);
        } else if (fieldDataType.isSupertypeOf(structure)) {
            field.$$isStructure$$ = true;
            const FieldConstructor = makeStructure(fieldDataType);
            assert(_.isFunction(FieldConstructor));
            //xx field
            field.$$func_encode$$ = struct_encode;
            field.$$func_decode$$ = struct_decode;
            field.$$Constructor$$ = FieldConstructor;
            field.$$initialize$$  = initialize_Structure.bind(null,field);
        } else {
            const stuff = findBuiltInType(fieldDataType.browseName.name);
            field.$$func_encode$$ = stuff.encode;
            field.$$func_decode$$ = stuff.decode;
            assert(_.isFunction(field.$$func_encode$$));
            assert(_.isFunction(field.$$func_decode$$));
            field.schema = stuff;
            field.$$initialize$$ = initialize_field.bind(null,field);
        }
        if (field.valueRank === 1) {
            field.$$initialize$$  = initialize_array.bind(null,field.$$initialize$$);
            field.$$func_encode$$ = encode_array.bind(null,field.$$func_encode$$);
            field.$$func_decode$$ = decode_array.bind(null,field.$$func_decode$$);

        }
    }

    // reconstruct _schema form
github node-opcua / node-opcua / packages / node-opcua-variant / schemas / Variant_schema.js View on Github external
function get_encoder(dataType) {
    const encode = factories.findBuiltInType(dataType.key).encode;
    /* istanbul ignore next */
    if (!encode) {
        throw new Error("Cannot find encode function for dataType " + dataType.key);
    }
    return encode;
}
github node-opcua / node-opcua / packages / node-opcua-address-space / src / ua_variable.ts View on Github external
return true;
    }
    if (variantDataType === DataType.Null) {
        return true;
    }

    let builtInType: string;
    let builtInUADataType: UADataTypePublic;

    const destUADataType = addressSpace.findNode(dataTypeNodeId) as UADataType;
    assert(destUADataType instanceof UADataType);

    if (destUADataType.isAbstract || destUADataType.nodeId.namespace !== 0) {
        builtInUADataType = destUADataType;
    } else {
        builtInType = findBuiltInType(destUADataType.browseName).name;
        builtInUADataType = addressSpace.findDataType(builtInType)!;
    }
    assert(builtInUADataType instanceof UADataType);

    const enumerationUADataType = addressSpace.findDataType("Enumeration");
    if (!enumerationUADataType) {
        throw new Error("cannot find Enumeration DataType node in standard address space");
    }
    if (destUADataType.isSupertypeOf(enumerationUADataType)) {
        return true;
    }

    // The value supplied for the attribute is not of the same type as the  value.
    const variantUADataType = _dataType_toUADataType(addressSpace, variantDataType);
    assert(variantUADataType instanceof UADataType);
github node-opcua / node-opcua / packages / node-opcua-address-space / src / extension_object_array_node.ts View on Github external
field.$$isStructure$$ = false;
        if (fieldDataType.isSupertypeOf(enumeration as any)) {
            field.$$isEnum$$ = true;
            // todo repair
            // makeEnumeration(fieldDataType);
        } else if (fieldDataType.isSupertypeOf(structure as any)) {
            field.$$isStructure$$ = true;
            const FieldConstructor = makeStructure(dataTypeFactory, fieldDataType);
            assert(_.isFunction(FieldConstructor));
            // xx field
            field.$$func_encode$$ = struct_encode;
            field.$$func_decode$$ = struct_decode;
            field.$$Constructor$$ = FieldConstructor;
            field.$$initialize$$ = initialize_Structure.bind(null, field);
        } else {
            const stuff = findBuiltInType(fieldDataType.browseName.name);
            field.$$func_encode$$ = stuff.encode;
            field.$$func_decode$$ = stuff.decode;
            assert(_.isFunction(field.$$func_encode$$));
            assert(_.isFunction(field.$$func_decode$$));
            field.schema = stuff;
            field.$$initialize$$ = initialize_field.bind(null, field);
        }
        if (field.valueRank === 1) {
            field.$$initialize$$ = initialize_array.bind(null, field.$$initialize$$);
            field.$$func_encode$$ = encode_array.bind(null, field.$$func_encode$$);
            field.$$func_decode$$ = decode_array.bind(null, field.$$func_decode$$);
        }
    }

    // reconstruct _schema form
    const fields = [];
github node-opcua / node-opcua / packages / node-opcua-variant / schemas / Variant_schema.js View on Github external
function get_decoder(dataType) {
    const decode = factories.findBuiltInType(dataType.key).decode;
    /* istanbul ignore next */
    if (!decode) {
        throw new Error("Variant.decode : cannot find decoder for type " + dataType.key);
    }
    return decode;
}
const displayWarning = true;
github node-opcua / node-opcua / packages / node-opcua-variant / source / variant.ts View on Github external
function decodeDebugVariant(self: Variant, stream: BinaryStream, options: any): void {

  const tracer = options.tracer;

  const encodingByte = decodeUInt8(stream);

  const isArray = ((encodingByte & VARIANT_ARRAY_MASK) === VARIANT_ARRAY_MASK);
  const hasDimension = ((encodingByte & VARIANT_ARRAY_DIMENSIONS_MASK) === VARIANT_ARRAY_DIMENSIONS_MASK);

  self.dataType = (encodingByte & VARIANT_TYPE_MASK) as DataType;

  tracer.dump("dataType:  ", self.dataType);
  tracer.dump("isArray:   ", isArray ? "true" : "false");
  tracer.dump("dimension: ", hasDimension);

  const decode = findBuiltInType(DataType[self.dataType]).decode;

  /* istanbul ignore next */
  if (!decode) {
    throw new Error("Variant.decode : cannot find decoder for type " + DataType[self.dataType]);
  }

  const cursorBefore = stream.length;

  if (isArray) {
    self.arrayType = hasDimension ? VariantArrayType.Matrix : VariantArrayType.Array;
    _decodeVariantArrayDebug(stream, decode, tracer, self.dataType);
  } else {
    self.arrayType = VariantArrayType.Scalar;
    self.value = decode(stream);
    tracer.trace("member", "Variant", self.value, cursorBefore, stream.length, DataType[self.dataType]);
  }
github node-opcua / node-opcua / packages / node-opcua-address-space / source / helpers / argument_list.ts View on Github external
function myfindBuiltInType(dataType: DataType): any {
    return factories.findBuiltInType(DataType[dataType]);
}