How to use node-opcua-basic-types - 10 common examples

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
assert(value !== undefined);

      if (isEnumerationItem(value)) {
        // value is a enumeration of some sort
        value = value.value;
      } else {
        value = parseInt(value, 10);
      }
      /* istanbul ignore next */
      if (!_.isFinite(value)) {
        // xx console.log("xxx ", value, ttt);
        throw new Error("expecting a number " + value);
      }
      break;
    case DataType.UInt64:
      value = coerceUInt64(value);
      break;
    case DataType.Int64:
      value = coerceInt64(value);
      break;
    case DataType.ExtensionObject:
      break;
    case DataType.DateTime:
      assert(value === null || value instanceof Date);
      break;
    case DataType.String:
      assert(typeof value === "string" || value === null);
      break;
    case DataType.ByteString:
      value = (typeof value === "string") ? Buffer.from(value) : value;

      // istanbul ignore next
github node-opcua / node-opcua / packages / node-opcua-variant / source / variant.ts View on Github external
function _decodeVariantArrayDebug(stream: BinaryStream, decode: any, tracer: any, dataType: DataType) {

  let cursorBefore = stream.length;
  const length = decodeUInt32(stream);

  let i;
  let element;
  tracer.trace("start_array", "Variant", length, cursorBefore, stream.length);

  const n1 = Math.min(10, length);

  // display a maximum of 10 elements
  for (i = 0; i < n1; i++) {
    tracer.trace("start_element", "", i);
    cursorBefore = stream.length;
    element = decode(stream);
    // arr.push(element);
    tracer.trace("member", "Variant", element, cursorBefore, stream.length, DataType[dataType]);
    tracer.trace("end_element", "", i);
  }
github node-opcua / node-opcua / packages / node-opcua-variant / schemas / Variant_schema.js View on Github external
function _decodeVariantArrayDebug(stream, decode, tracer, dataType) {

    let cursor_before = stream.length;
    const length = ec.decodeUInt32(stream);
    let i, element;
    tracer.trace("start_array", "Variant", length, cursor_before, stream.length);

    const n1 = Math.min(10, length);
    // display a maximum of 10 elements
    for (i = 0; i < n1; i++) {
        tracer.trace("start_element", "", i);
        cursor_before = stream.length;
        element = decode(stream);
        // arr.push(element);
        tracer.trace("member", "Variant", element, cursor_before, stream.length, dataType.key);
        tracer.trace("end_element", "", i);
    }
    // keep reading
    if (length >= n1) {
        for (i = n1; i < length; i++) {
github node-opcua / node-opcua / packages / node-opcua-packet-analyzer / source / packet_analyzer / packet_analyzer.ts View on Github external
function display_encodeable(value: any, buffer1: Buffer, start: number, end: number) {
        const bufferExtract = buffer1.slice(start, end);
        const stream = new BinaryStream(bufferExtract);
        const nodeId = decodeNodeId(stream);
        const encodingMask = decodeByte(stream); // 1 bin 2: xml
        const length = decodeUInt32(stream);

        display(chalk.green("     ExpandedNodId =") + " " + nodeId);
        display(chalk.green("     encoding mask =") + " " + encodingMask);
        display(chalk.green("            length =") + " " + length);
        analyzePacket(bufferExtract.slice(stream.length), value.encodingDefaultBinary, padding + 2, start + stream.length);

    }
github node-opcua / node-opcua / packages / node-opcua-transport / source / AcknowledgeMessage.ts View on Github external
public decode(stream: BinaryStream): void {
        // call base class implementation first
        super.decode(stream);
        this.protocolVersion = decodeUInt32(stream);
        this.receiveBufferSize = decodeUInt32(stream);
        this.sendBufferSize = decodeUInt32(stream);
        this.maxMessageSize = decodeUInt32(stream);
        this.maxChunkCount = decodeUInt32(stream);
    }
}
github node-opcua / node-opcua / packages / node-opcua-data-model / source / diagnostic_info.ts View on Github external
function decode_DiagnosticInfo(diagnosticInfo: DiagnosticInfo, stream: BinaryStream): void {

    const encodingMask = decodeByte(stream);

    // read symbolic id
    if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
        diagnosticInfo.symbolicId = decodeInt32(stream);
    }
    // read namespace uri
    if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
        diagnosticInfo.namespaceURI = decodeInt32(stream);
    }
    // read locale
    if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
        diagnosticInfo.locale = decodeInt32(stream);
    }
    // read localized text
    if (encodingMask & DiagnosticInfo_EncodingByte.LocalizedText) {
        diagnosticInfo.localizedText = decodeInt32(stream);
    }
    // read additional info
    if (encodingMask & DiagnosticInfo_EncodingByte.AdditionalInfo) {
        diagnosticInfo.additionalInfo = decodeString(stream);
    }
    // read inner status code
    if (encodingMask & DiagnosticInfo_EncodingByte.InnerStatusCode) {
        diagnosticInfo.innerStatusCode = decodeStatusCode(stream);
    }
    // read inner status code
    if (encodingMask & DiagnosticInfo_EncodingByte.InnerDiagnosticInfo) {
        diagnosticInfo.innerDiagnosticInfo = new DiagnosticInfo({});
github node-opcua / node-opcua / packages / node-opcua-data-model / source / diagnostic_info.ts View on Github external
// read symbolic id
    if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
        diagnosticInfo.symbolicId = decodeInt32(stream);
        tracer.trace("member", "symbolicId", diagnosticInfo.symbolicId, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read namespace uri
    if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
        diagnosticInfo.namespaceURI = decodeInt32(stream);
        tracer.trace("member", "symbolicId", diagnosticInfo.namespaceURI, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read locale
    if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
        diagnosticInfo.locale = decodeInt32(stream);
        tracer.trace("member", "locale", diagnosticInfo.locale, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read localized text
    if (encodingMask & DiagnosticInfo_EncodingByte.LocalizedText) {
        diagnosticInfo.localizedText = decodeInt32(stream);
        tracer.trace("member", "localizedText", diagnosticInfo.localizedText, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read additional info
    if (encodingMask & DiagnosticInfo_EncodingByte.AdditionalInfo) {
        diagnosticInfo.additionalInfo = decodeString(stream);
        tracer.trace("member", "additionalInfo", diagnosticInfo.additionalInfo, cursorBefore, stream.length, "String");
        cursorBefore = stream.length;
    }
    // read inner status code
github node-opcua / node-opcua / packages / node-opcua-data-model / source / diagnostic_info.ts View on Github external
const encodingMask = decodeByte(stream);

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

    cursorBefore = stream.length;

    // read symbolic id
    if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
        diagnosticInfo.symbolicId = decodeInt32(stream);
        tracer.trace("member", "symbolicId", diagnosticInfo.symbolicId, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read namespace uri
    if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
        diagnosticInfo.namespaceURI = decodeInt32(stream);
        tracer.trace("member", "symbolicId", diagnosticInfo.namespaceURI, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read locale
    if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
        diagnosticInfo.locale = decodeInt32(stream);
        tracer.trace("member", "locale", diagnosticInfo.locale, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read localized text
    if (encodingMask & DiagnosticInfo_EncodingByte.LocalizedText) {
        diagnosticInfo.localizedText = decodeInt32(stream);
        tracer.trace("member", "localizedText", diagnosticInfo.localizedText, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read additional info
github node-opcua / node-opcua / packages / node-opcua-data-model / source / diagnostic_info.ts View on Github external
function decode_DiagnosticInfo(diagnosticInfo: DiagnosticInfo, stream: BinaryStream): void {

    const encodingMask = decodeByte(stream);

    // read symbolic id
    if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
        diagnosticInfo.symbolicId = decodeInt32(stream);
    }
    // read namespace uri
    if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
        diagnosticInfo.namespaceURI = decodeInt32(stream);
    }
    // read locale
    if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
        diagnosticInfo.locale = decodeInt32(stream);
    }
    // read localized text
    if (encodingMask & DiagnosticInfo_EncodingByte.LocalizedText) {
        diagnosticInfo.localizedText = decodeInt32(stream);
    }
    // read additional info
    if (encodingMask & DiagnosticInfo_EncodingByte.AdditionalInfo) {
        diagnosticInfo.additionalInfo = decodeString(stream);
    }
    // read inner status code
    if (encodingMask & DiagnosticInfo_EncodingByte.InnerStatusCode) {
        diagnosticInfo.innerStatusCode = decodeStatusCode(stream);
github node-opcua / node-opcua / packages / node-opcua-data-model / source / diagnostic_info.ts View on Github external
const tracer = options.tracer;

    tracer.trace("start", options.name + "(" + "DiagnosticInfo" + ")", stream.length, stream.length);

    let cursorBefore = stream.length;
    const encodingMask = decodeByte(stream);

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

    cursorBefore = stream.length;

    // read symbolic id
    if (encodingMask & DiagnosticInfo_EncodingByte.SymbolicId) {
        diagnosticInfo.symbolicId = decodeInt32(stream);
        tracer.trace("member", "symbolicId", diagnosticInfo.symbolicId, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read namespace uri
    if (encodingMask & DiagnosticInfo_EncodingByte.NamespaceURI) {
        diagnosticInfo.namespaceURI = decodeInt32(stream);
        tracer.trace("member", "symbolicId", diagnosticInfo.namespaceURI, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read locale
    if (encodingMask & DiagnosticInfo_EncodingByte.Locale) {
        diagnosticInfo.locale = decodeInt32(stream);
        tracer.trace("member", "locale", diagnosticInfo.locale, cursorBefore, stream.length, "Int32");
        cursorBefore = stream.length;
    }
    // read localized text