How to use the node-opcua.Variant function in node-opcua

To help you get started, we’ve selected a few node-opcua 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-end2end-test / test_helpers / bin / simple_server_with_no_transferSubscription.js View on Github external
server.on("post_initialize", function () {

    const addressSpace = server.engine.addressSpace;

    const rootFolder = addressSpace.findNode("RootFolder");

    const namespace = addressSpace.getOwnNamespace();

    const myDevices = namespace.addFolder(rootFolder.objects, {browseName: "MyDevices"});

    const variable0 = namespace.addVariable({
        organizedBy: myDevices,
        browseName: "Counter",
        nodeId: "ns=1;s=MyCounter",
        dataType: "Int32",
        value: new opcua.Variant({dataType: opcua.DataType.Int32, value: 1000.0})
    });

    server._on_TransferSubscriptionsRequest =(message /* :Message*/, channel/*: ServerSecureChannelLayer*/) => {
        const response = new opcua.TransferSubscriptionsResponse({
            responseHeader: { serviceResult: opcua.StatusCodes.BadNotImplemented }
        });
        return channel.send_response("MSG", response, message);
    }

});
github node-opcua / node-opcua / packages / node-opcua-end2end-test / test_helpers / bin / simple_server_that_terminate_session_too_early.js View on Github external
server.on("post_initialize", function () {

    const addressSpace = server.engine.addressSpace;

    const rootFolder = addressSpace.findNode("RootFolder");

    const namespace = addressSpace.getOwnNamespace();

    const myDevices = namespace.addFolder(rootFolder.objects, {browseName: "MyDevices"});

    const variable0 = namespace.addVariable({
        organizedBy: myDevices,
        browseName: "Counter",
        nodeId: "ns=1;s=MyCounter",
        dataType: "Int32",
        value: new opcua.Variant({dataType: opcua.DataType.Int32, value: 1000.0})
    });

    // Add a mechanism to dismiss session early
    const obj = namespace.addObject({ 
        nodeId: "ns=1;s=MyObject",
        browseName: "MyObject" ,
        organizedBy: myDevices,
    });

    const simulateNetworkOutage = namespace.addMethod(obj, {
        browseName: "SimulateNetworkOutage",
        executable: true,
        inputArguments: [
            {
                name: "outageDuration",
                description: {text: "specifies the number of miliseconds the Outage should be"},
github node-opcua / node-opcua / packages / node-opcua-end2end-test / test_helpers / bin / simple_server_with_custom_extension_objects.js View on Github external
server.on("post_initialize", function () {

    const addressSpace = server.engine.addressSpace;

    const rootFolder = addressSpace.findNode("RootFolder");

    const namespace = addressSpace.getOwnNamespace();

    const myDevices = namespace.addFolder(rootFolder.objects, {browseName: "MyDevices"});

    const variable0 = namespace.addVariable({
        organizedBy: myDevices,
        browseName: "Counter",
        nodeId: "ns=1;s=MyCounter",
        dataType: "Int32",
        value: new opcua.Variant({dataType: opcua.DataType.Int32, value: 1000.0})
    });

});
github node-opcua / node-opcua / documentation / weather.js View on Github external
function extract_value(dataType,city_name,property) {
    const city = city_data_map[city_name];
    if (!city) {
        return opcua.StatusCodes.BadDataUnavailable
    }

    const value = city[property];
    return new opcua.Variant({dataType, value: value });
}
github PacktPublishing / Industrial-Internet-Application-Development / Chapter03 / opcua / hub / index.js View on Github external
function (cb) {
      session.writeSingleNode("ns=1;s=Variable1", new opcua.Variant({
        dataType: opcua.DataType.Double,
        value: 100
      }), function (err) {
        cb(err);
      });
    },