How to use node-opcua-guid - 5 common examples

To help you get started, we’ve selected a few node-opcua-guid 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-nodeid / source / nodeid.ts View on Github external
constructor(identifierType: NodeIdType, value: any, namespace?: number) {

        this.identifierType = identifierType;
        this.value = value;
        this.namespace = namespace || 0;

        // namespace shall be a UInt16
        assert(this.namespace >= 0 && this.namespace <= 0xFFFF);

        assert(this.identifierType !== NodeIdType.NUMERIC || (this.value >= 0 && this.value <= 0xFFFFFFFF));
        assert(this.identifierType !== NodeIdType.GUID || isValidGuid(this.value as string));
        assert(this.identifierType !== NodeIdType.STRING || typeof this.value === "string");

    }
github node-opcua / node-opcua / packages / node-opcua-nodeid / source / nodeid.ts View on Github external
export function makeNodeId(value: string | Buffer | number, namespace?: number) {

    value = value || 0;
    namespace = namespace || 0;

    let identifierType = NodeIdType.NUMERIC;
    if (typeof value === "string") {
        if (value.match(/^(s|g|b|i)=/)) {
            throw new Error("please use coerce NodeId instead");
        }
        //            1         2         3
        //  012345678901234567890123456789012345
        // "72962B91-FA75-4AE6-8D28-B404DC7DAF63"
        if (isValidGuid(value)) {
            identifierType = NodeIdType.GUID;
        } else {
            identifierType = NodeIdType.STRING;
            // detect accidental string of form "ns=x;x";
            assert(value.indexOf("ns=") === -1, " makeNodeId(string) ? did you mean using coerceNodeId instead? ");
        }
    } else if (value instanceof Buffer) {
        identifierType = NodeIdType.BYTESTRING;
    }

    const nodeId = new NodeId(identifierType, value, namespace);

    assert(nodeId.hasOwnProperty("identifierType"));

    return nodeId;
}
github node-opcua / node-opcua / packages / node-opcua-basic-types / source / guid.ts View on Github external
export function encodeGuid(guid: Guid, stream: BinaryStream): void {
    if (!isValidGuid(guid)) {
        throw new Error(" Invalid GUID : '" + JSON.stringify(guid) + "'");
    }
    //           1         2         3
    // 012345678901234567890123456789012345
    // |        |    |    | |  | | | | | |
    // 12345678-1234-1234-ABCD-0123456789AB
    // 00000000-0000-0000-0000-000000000000";
    function write_UInt32(starts: number[]) {
        const n = starts.length;
        for (let i = 0; i < n; i++) {
            const start = starts[i];
            stream.writeUInt32(parseInt(guid.substr(start, 8), 16));
        }
    }

    function write_UInt16(starts: number[]) {
github node-opcua / node-opcua / packages / node-opcua-factory / src / factories_builtin_types.js View on Github external
"use strict";
/**
 * @module opcua.miscellaneous
 */


const _ = require("underscore");
const assert = require("node-opcua-assert").assert;
const util = require("util");


const ec = require("node-opcua-basic-types");
const sc = require("node-opcua-status-code");
const emptyGuid = require("node-opcua-guid").emptyGuid;



exports.minDate = new Date(Date.UTC(1601, 0, 1, 0, 0));


//there are 4 types of DataTypes in opcua:
//   Built-In DataType
//   Simple DataType
//   Complex DataType
//   Enumeration


const defaultXmlElement = "";

// Built-In Type
github node-opcua / node-opcua / packages / node-opcua-nodeid / source / nodeid.ts View on Github external
} else if (twoFirst === "s=") {

            identifierType = NodeIdType.STRING;
            value = value.substr(2);

        } else if (twoFirst === "b=") {

            identifierType = NodeIdType.BYTESTRING;
            value = Buffer.from(value.substr(2), "hex");

        } else if (twoFirst === "g=") {

            identifierType = NodeIdType.GUID;
            value = value.substr(2);

        } else if (isValidGuid(value)) {

            identifierType = NodeIdType.GUID;

        } else if ((matches = regexNamespaceI.exec(value)) !== null) {
            identifierType = NodeIdType.NUMERIC;
            namespace = parseInt(matches[1], 10);
            value = parseInt(matches[2], 10);

        } else if ((matches = regexNamespaceS.exec(value)) !== null) {

            identifierType = NodeIdType.STRING;
            namespace = parseInt(matches[1], 10);
            value = matches[2];

        } else if ((matches = regexNamespaceB.exec(value)) !== null) {
            identifierType = NodeIdType.BYTESTRING;

node-opcua-guid

pure nodejs OPCUA SDK - module guid

MIT
Latest version published 4 months ago

Package Health Score

83 / 100
Full package analysis