How to use the node-opcua-basic-types.decodeUInt8 function in node-opcua-basic-types

To help you get started, we’ve selected a few node-opcua-basic-types 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-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]);
  }
github node-opcua / node-opcua / packages / node-opcua-data-value / source / datavalue.ts View on Github external
function decodeDataValueInternal(dataValue: DataValue, stream: BinaryStream) {

  const encodingMask = decodeUInt8(stream);
  if (encodingMask & DataValueEncodingByte.Value) {
    dataValue.value = new Variant();
    dataValue.value.decode(stream);
  }
  // read statusCode
  if (encodingMask & DataValueEncodingByte.StatusCode) {
    dataValue.statusCode = decodeStatusCode(stream);
  } else {
    dataValue.statusCode = StatusCodes.Good;
  }

  dataValue.sourcePicoseconds = 0;
  // read sourceTimestamp
  if (encodingMask & DataValueEncodingByte.SourceTimestamp) {
    dataValue.sourceTimestamp = decodeHighAccuracyDateTime(stream);
    dataValue.sourcePicoseconds += (dataValue.sourceTimestamp as DateWithPicoseconds).picoseconds | 0;
github node-opcua / node-opcua / packages / node-opcua-data-value / source / datavalue.ts View on Github external
function decodeDebugDataValue(dataValue: DataValue, stream: BinaryStream, options: any) {

  const tracer = options.tracer;

  let cur = stream.length;
  const encodingMask = decodeUInt8(stream);
  assert(encodingMask <= 0x3F);

  tracer.trace("member", "encodingByte", "0x" + encodingMask.toString(16), cur, stream.length, "Mask");
  tracer.encoding_byte(encodingMask, DataValueEncodingByte, cur, stream.length);

  if (encodingMask & DataValueEncodingByte.Value) {
    dataValue.value = new Variant();
    dataValue.value.decodeDebug(stream, options);
  }
  // read statusCode
  cur = stream.length;
  if (encodingMask & DataValueEncodingByte.StatusCode) {
    dataValue.statusCode = decodeStatusCode(stream);
    tracer.trace("member", "statusCode", dataValue.statusCode, cur, stream.length, "StatusCode");
  }
  // read sourceTimestamp
github node-opcua / node-opcua / packages / node-opcua-data-value / schemas / DataValue_schema.js View on Github external
decode_debug: function(dataValue,stream,options) {

        const tracer = options.tracer;

        let cur = stream.length;
        const encoding_mask = ec.decodeUInt8(stream);
        assert(encoding_mask<=0x3F);

        tracer.trace("member", "encodingByte", "0x" + encoding_mask.toString(16), cur, stream.length, "Mask");
        tracer.encoding_byte(encoding_mask,DataValueEncodingByte,cur,stream.length);

        if( check_flag(encoding_mask,DataValueEncodingByte.Value)) {
            //xx var Variant = require("./variant").Variant;
            dataValue.value = new Variant();
            dataValue.value.decode_debug(stream,options);
            //xx if (tracer) { tracer.trace("member","statusCode", dataValue.value,cur,stream.length,"Variant"); }
        }
        // read statusCode
        cur = stream.length;
        if (check_flag(encoding_mask,DataValueEncodingByte.StatusCode)) {
            dataValue.statusCode  = ec.decodeStatusCode(stream);
            tracer.trace("member","statusCode", dataValue.statusCode,cur,stream.length,"StatusCode");
github node-opcua / node-opcua / packages / node-opcua-data-value / schemas / DataValue_schema.js View on Github external
decode: function(dataValue,stream,options) {

        const encoding_mask = ec.decodeUInt8(stream);

        if( check_flag(encoding_mask,DataValueEncodingByte.Value)) {
            //xx var Variant =
            // re("./variant").Variant;
            dataValue.value = new Variant(null);
            dataValue.value.decode(stream,options);
        }
        // read statusCode
        if (check_flag(encoding_mask,DataValueEncodingByte.StatusCode)) {
            dataValue.statusCode  = ec.decodeStatusCode(stream);
        } else {
            dataValue.statusCode = StatusCodes.Good;
        }

        dataValue.sourcePicoseconds = 0;
        // read sourceTimestamp
github node-opcua / node-opcua / packages / node-opcua-variant / schemas / Variant_schema.js View on Github external
decode: function (self, stream) {

        const encodingByte = ec.decodeUInt8(stream);

        const isArray = ((encodingByte & Variant_ArrayMask) === Variant_ArrayMask);

        const hasDimension = (( encodingByte & Variant_ArrayDimensionsMask  ) === Variant_ArrayDimensionsMask);

        self.dataType = DataType.get(encodingByte & Variant_TypeMask);

        if (!self.dataType) {
            throw new Error("cannot find DataType for encodingByte = 0x" + (encodingByte & Variant_TypeMask).toString(16));
        }
        if (isArray) {
            self.arrayType = hasDimension ? VariantArrayType.Matrix : VariantArrayType.Array;
            self.value = decodeVariantArray(self.dataType, stream);
        }
        else {
            self.arrayType = VariantArrayType.Scalar;
github node-opcua / node-opcua / packages / node-opcua-variant / source / variant.ts View on Github external
function internalDecodeVariant(self: Variant, stream: BinaryStream) {

  const encodingByte = decodeUInt8(stream);

  const isArray: boolean = ((encodingByte & VARIANT_ARRAY_MASK) === VARIANT_ARRAY_MASK);

  const hasDimension: boolean = ((encodingByte & VARIANT_ARRAY_DIMENSIONS_MASK) === VARIANT_ARRAY_DIMENSIONS_MASK);

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

  if (isArray) {
    self.arrayType = hasDimension ? VariantArrayType.Matrix : VariantArrayType.Array;
    self.value = decodeVariantArray(self.dataType, stream);
  } else {
    self.arrayType = VariantArrayType.Scalar;
    const decode = get_decoder(self.dataType);
    self.value = decode(stream);
  }
  if (hasDimension) {